lightbulb/services/access_token
Types
Represents an OAuth2 access token for LTI 1.3 services.
pub type AccessToken {
AccessToken(
token: String,
token_type: String,
expires_in: Int,
scope: String,
)
}
Constructors
-
AccessToken( token: String, token_type: String, expires_in: Int, scope: String, )
Values
pub fn fetch_access_token(
providers: Providers,
registration: Registration,
scopes: List(String),
) -> Result(AccessToken, String)
Requests an OAuth2 access token. Returns Ok(AccessToken) on success, Error(_) otherwise.
As parameters, expects:
providers
: AProviders
instance that contains the HTTP provider and data provider.registration
: ARegistration
instance used to fetch the access token endpoint and client ID.scopes
: A list of scopes to request for the access token.
Examples:
fetch_access_token(providers, registration, ["https://purl.imsglobal.org/spec/lti-ags/scope/lineitem"])
// Ok(AccessToken("actual_access_token", "Bearer", 3600, "https://purl.imsglobal.org/spec/lti-ags/scope/lineitem"))
pub fn set_authorization_header(
req: Request(String),
access_token: AccessToken,
) -> Request(String)
Sets the Authorization header for a request using the provided access token.