OAuth2Client
Index
Constructors
constructor
Constructs an OAuth2Client for the given domain.
Parameters
args: { authentication: IOAuth2ClientAuthentication; baseURL: URL; clientId: String; network: any; scopes: String }
authentication: IOAuth2ClientAuthentication
baseURL: URL
clientId: String
network: any
scopes: String
Returns OAuth2Client
Properties
optionaladditionalHttpHeaders
Additional HTTP headers to include in outgoing network requests.
readonlyconfiguration
The configuration that identifies this OAuth2 client.
optionalreadonlyjwks
The JWKS key set for this org.
This value will be nil until the keys have been retrieved through the `jwks(completion:)` or `jwks()` functions.
readonlynetwork
The URLSession used by this client for network requests.
optionalreadonlyopenIdConfiguration
The OpenID configuration for this org.
This value will be nil until the configuration has been retrieved through the `openIdConfiguration(completion:)` or `openIdConfiguration()` functions.
Methods
exchange
Attempts to exchange, and verify, a token from the supplied request.
This also ensures the JWKS keyset is retrieved in parallel (if it hasn't already been cached), and verifies the ID and Access tokens to ensure validity.
Type parameters
- T: TokenRequest
Parameters
tokenRequest: T
Returns Promise<APIResponse<Token>>
fetchJwks
fetchOpenIdConfiguration
Retrieves the org's OpenID configuration.
If this value has recently been retrieved, the cached result is returned.
Returns Promise<OpenIdConfiguration>
The OpenID configuration for the org identified by the client's base URL.
introspect
Introspects the given token information.
- Parameters:
Parameters
token: Token
Token to introspect
type: TokenType
The type of value to introspect.
Returns Promise<TokenInfo>
refresh
Attempts to refresh the supplied token, using the Token.refreshToken if it is available.
This method prevents multiple concurrent refresh requests to be performed for a given token, though all applicable completion blocks will be invoked once the token refresh has completed.
Parameters
token: Token
Token to refresh.
Returns Promise<Token>
The new Token created from the refresh.
revoke
Attempts to revoke the given token.
A Token object may represent multiple token types, such as Token.accessToken or Token.refreshToken. These individual token types can be targeted to be revoked.
- Parameters:
Parameters
token: Token
Token object.
type: TokenRevokeType
Type of token to revoke.
Returns Promise<void>
An OAuth2 client, used to interact with a given authorization server.