D2lvalenceElixir.Auth.D2LAppContext (D2lvalenceElixir v0.1.0) View Source

Generic base module for a Valence Learning Framework API client application.

Link to this section Summary

Functions

Build a URL that the user's browser can employ to complete the user authentication process with the back-end LMS.

Build a new authentication LMS-user context for a Valence Learning Framework API client application.

Creates the struct with the context information

Link to this section Functions

Link to this function

create_anonymous_user_context(app_context, host, options \\ [])

View Source
Link to this function

create_url_for_authentication(app_context, host, client_app_url, connect_type \\ nil, encrypt_request \\ true)

View Source

Build a URL that the user's browser can employ to complete the user authentication process with the back-end LMS.

:param host: Host/port string for the back-end LMS service (i.e. lms.someUni.edu:443). To this parameter, this function adds the appropriate API route and parameters for a user-authentication request. :param client_app_url: Client application URL that the back-end service should redirect the user back to after user-authentication. :param connect_type: Provide a type string value of mobile to signal to the back-end service that the user-context will connect from a mobile device. :param encrypt_request: If true (default), generate an URL using a secure scheme (HTTPS); otherwise, generate an URL for an unsecure scheme (HTTP).

Examples

iex> D2lvalenceElixir.Auth.D2LAppContext.create_url_for_authentication(%D2lvalenceElixir.Auth.D2LAppContext{app_id: "J5fm9B0Rq934mBQV9fGLWP", app_key: "rYBPwHlBy0wPxlP-QZPedr"}, "lms.someUni.edu:443", "http://localhost:8080/token")
"https://lms.someUni.edu:443/d2l/auth/api/token?x_a=J5fm9B0Rq934mBQV9fGLWP&x_b=-4KVKL-uNYeXopvBXFdM0SHZgyiQCVWu0oDmF5JkL48&x_target=http%3A%2F%2Flocalhost%3A8080%2Ftoken"
Link to this function

create_user_context(app_context, options \\ [])

View Source

Specs

create_user_context(
  %D2lvalenceElixir.Auth.D2LAppContext{app_id: term(), app_key: term()},
  [
    result_uri: String.t(),
    host: String.t(),
    encrypt_requests: true | false,
    d2l_user_context_props_dict: %{}
  ]
  | []
) ::
  {:error, String.t()}
  | {:ok,
     %D2lvalenceElixir.Auth.D2LUserContext{
       anonymous: false | true,
       app_id: String.t(),
       app_key: String.t(),
       encrypt_requests: true | false,
       host: String.t(),
       scheme: String.t(),
       server_skew: String.t(),
       user_id: String.t(),
       user_key: String.t()
     }}

Build a new authentication LMS-user context for a Valence Learning Framework API client application.

:param result_uri:

Entire result URI, including quoted parameters, that the back-end
service redirected the user to after user-authentication.

:param host:

Host/port string for the back-end service
(i.e. `lms.someUni.edu:443`).

:param encrypt_requests:

If true, use HTTPS for requests made through the resulting built
user context; if false (the default), use HTTP.

:param d2l_user_context_props_dict:

If the client application already has access to the properties
dictionary saved from a previous user context, it can provide it
with this property. If this paramter is not `None`, this builder
function ignores the `result_uri` parameter as not
needed.

Specs

new(String.t(), String.t()) :: %D2lvalenceElixir.Auth.D2LAppContext{
  app_id: String.t(),
  app_key: String.t()
}

Creates the struct with the context information