Ltix.OAuth (Ltix v0.1.0)

Copy Markdown View Source

OAuth 2.0 client credentials authentication for LTI Advantage services.

Acquires an access token from the platform's token endpoint and returns an authenticated Ltix.OAuth.Client ready for service calls.

Single service

{:ok, client} = Ltix.OAuth.authenticate(registration,
  endpoints: %{Ltix.MembershipsService => endpoint}
)

Multiple services

{:ok, client} = Ltix.OAuth.authenticate(registration,
  endpoints: %{
    Ltix.MembershipsService => memberships_endpoint,
    Ltix.GradeService => ags_endpoint
  }
)

Scopes from all endpoints are combined into a single token request.

Options

  • :endpoints (map/0) - Required. Map of service modules to endpoint structs.

  • :req_options (keyword/0) - Options passed through to Req.request/2. The default value is [].

Summary

Functions

Given a registration, authenticate with a platform's token endpoint.

Functions

authenticate(registration, opts \\ [])

@spec authenticate(
  Ltix.Registration.t(),
  keyword()
) :: {:ok, Ltix.OAuth.Client.t()} | {:error, Exception.t()}

Given a registration, authenticate with a platform's token endpoint.

Request scopes by passing service endpoints in the :endpoints option.

authenticate!(registration, opts \\ [])

@spec authenticate!(
  Ltix.Registration.t(),
  keyword()
) :: Ltix.OAuth.Client.t()

Same as authenticate/2 but raises on error.