Emits errors that occur during login, or when checking for an active session on startup.
Emits ID token claims when authenticated, or null if not authenticated.
Emits boolean values indicating the authentication state of
the user. If true, it means a user has
authenticated. This depends on the value of
isLoading$, so there is no need to manually
check the loading state of the SDK.
Emits boolean values indicating the loading state of the SDK.
Emits details about the authenticated user, or null if not authenticated.
buildAuthorizeUrl().subscribe(url => ...)
Builds an /authorize URL for
loginWithRedirect using the parameters provided as
arguments. Random and secure state and
nonce parameters will be auto-generated.
The options
A URL to the authorize endpoint
buildLogoutUrl().subscribe(url => ...)
Builds a URL to the logout endpoint.
The options used to configure the parameters that appear in the logout endpoint URL.
a URL to the logout endpoint using the parameters provided as arguments.
Fetches a new access token and returns the response from the /oauth/token endpoint, omitting the refresh token.
The options for configuring the token fetch.
Fetches a new access token and returns it.
The options for configuring the token fetch.
getTokenWithPopup(options).subscribe(token => ...)
Get an access token interactively.
Opens a popup with the /authorize URL using
the parameters provided as arguments. Random and secure
state and nonce parameters will
be auto-generated. If the response is successful, results
will be valid according to their expiration times.
getIdTokenClaims(options).subscribe(claims => ...);
Returns all claims from the id_token if available.
If you provide an audience or scope, they should match an existing Access Token (the SDK stores a corresponding ID Token with every Access Token, and uses the scope and audience to look up the ID Token)
The options to get the Id token claims
getUser(options).subscribe(user => ...);
Returns the user information if available (decoded from
the id_token).
If you provide an audience or scope, they should match an existing Access Token (the SDK stores a corresponding ID Token with every Access Token, and uses the scope and audience to look up the ID Token)
The type to return, has to extend {@link User}.
The options to get the user
handleRedirectCallback(url).subscribe(result => ...)
After the browser redirects back to the callback page,
call handleRedirectCallback to handle success
and error responses from Authok. If the response is
successful, results will be valid according to their
expiration times.
Calling this method also refreshes the authentication and user states.
The URL to that should be used to retrieve the
state and code values.
Defaults to window.location.href if not
given.
await loginWithPopup(options);
Opens a popup with the /authorize URL using
the parameters provided as arguments. Random and secure
state and nonce parameters will
be auto-generated. If the response is successful, results
will be valid according to their expiration times.
IMPORTANT: This method has to be called from an event handler that was started by the user like a button click, for example, otherwise the popup will be blocked in most browsers.
The login options
Configuration for the popup window
loginWithRedirect(options);
Performs a redirect to /authorize using the
parameters provided as arguments. Random and secure
state and nonce parameters will
be auto-generated.
The login options
logout();
Clears the application session and performs a redirect to
/v1/logout, using the parameters provided as
arguments, to clear the Authok session. If the
federated option is specified it also clears
the Identity Provider session. If the
localOnly option is specified, it only clears
the application session. It is invalid to set both the
federated and localOnly options
to true, and an error will be thrown if you
do.
Read more about how Logout works at Authok.
The logout options
Called when the service is destroyed
Emits the value (if any) that was passed to the
loginWithRedirectmethod call but only afterhandleRedirectCallbackis first called