Lti_1p3.Tool.Services.AccessToken (Lti 1p3 v0.6.0)

Link to this section Summary

Functions

Requests an OAuth2 access token. Returns {:ok, %AccessToken{}} on success, {:error, error} otherwise.

Link to this section Types

@type t() :: %Lti_1p3.Tool.Services.AccessToken{
  access_token: String.t(),
  expires_in: integer(),
  scope: String.t(),
  token_type: String.t()
}

Link to this section Functions

Link to this function

fetch_access_token(map, scopes, host)

Requests an OAuth2 access token. Returns {:ok, %AccessToken{}} on success, {:error, error} otherwise.

As parameters, expects:

  1. The registration from which an access token is being requested
  2. A list of scopes being requested
  3. The host name of this instance of Torus

examples

Examples

iex> fetch_access_token(registration, scopes, host)
{:ok,
  %Lti_1p3.Tool.Services.AccessToken{
    "scope" => "https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
    "access_token" => "actual_access_token",
    "token_type" => "Bearer",
    "expires_in" => "3600"
  }
}

iex> fetch_access_token(bad_tool)
{:error, "invalid_scope"}