OpenIdConnectClient
Index
Methods
publicdisconnect
Returns void
publicgetAccessToken
Returns Promise<string>
access_token from the
/tokenendpoint.
publicgetIdentityToken
Provides an identity token from the Open ID connect provider.
Returns a cached value if there's sufficient time left until the id_token expires. If the id_token is about to expire a fresh token is fetched.
Returns Promise<IdentityToken>
parsed id_token from the
/tokenendpoint.
publicstaticclearLoginState
Removes the transient login parameters loginWithRedirect writes to session storage (the state, PKCE code verifier and redirect URI). create consumes and removes these on a successful token exchange; a caller that drives the login flow out of band (e.g. a popup or iframe login that ends by being closed or cancelled) can call this to clear the orphaned values so they do not linger for the tab's lifetime. The set of keys lives here, next to the code that writes and reads them.
Parameters
sessionStorage: Storage
Returns void
publicstaticcreate
Creates an Open ID Connect client that uses refresh tokens. Expects callbackState to be the values from the callback caused by loginWithRedirect.
See https://auth0.com/docs/get-started/authentication-and-authorization-flow/add-login-auth-code-flow
Parameters
clientOptions: OpenIdConnectClientOptions
specifies which Open ID provider to login with and the client credentials
callbackState: SuccessfulLoginCallbackState
code and state received from the query parameters in the callback caused by loginWithRedirect
createDependencies: Partial<CreateDependencies> = {}
dependency injection
Returns Promise<OpenIdConnectClient>
an Open ID Connect client that uses refresh tokens
publicstaticcreateFromTokenResponse
Parameters
response: Response
openIdProviderMetadata: OpenIdProviderMetadata
clientOptions: OpenIdConnectClientOptions
optionalcode_verifier: string
optionalredirect_uri: string
optionalfetch: typeof fetch
Returns Promise<OpenIdConnectClient>
publicstaticcreateWithClientCredentials
Creates an Open ID Connect client for a service using the client credentials grant — no user, no browser, no redirects: the client authenticates as itself with its ClientCredentialsOptions.clientSecret in a single request to the token endpoint. Tokens are renewed automatically by re-running the grant (the provider issues no refresh token for it).
The provider must have the client configured as a confidential client with service accounts enabled. Whether getIdentityToken works for clients created this way depends on the provider — see its documentation.
Parameters
options: ClientCredentialsOptions
dependencies: Partial<ClientCredentialsDependencies> = {}
Returns Promise<OpenIdConnectClient>
publicstaticloginWithRedirect
Initializes the login with redirect for code flow with the Open ID provider specified in clientOptions. The returned promise will never resolve. Awaiting the return value will block the continued execution of the promise chain.
See https://auth0.com/docs/get-started/authentication-and-authorization-flow/add-login-auth-code-flow
Parameters
clientOptions: OpenIdConnectClientOptions
specifies which Open ID provider to login with
loginWithRedirectDependencies: Partial<LoginWithRedirectDependencies> = {}
dependency injection
Returns Promise<never>
an unfulfilled promise that will never resolve
publicstaticprefetchedMetadataFetcher
Parameters
metadata: OpenIdProviderMetadata
Returns OpenIdConnectProviderMetadataFetcher
Provides an access token from the Open ID connect provider.
Returns a cached value if there's sufficient time left until the access_token expires. If the access_token is about to expire a fresh token is fetched.