AuthClient#loginWithRedirect(options);
The AuthClient
handles operations against the Auth Service APIs.
Name | Type | Required | Description |
---|---|---|---|
|
|
✅ |
The base URL of the authorization server.
|
|
|
✅ |
The client ID.
|
|
|
❌ |
The current customer account ID. Usually only used in B2B contexts.
|
|
|
✅ |
The agent used for making HTTP requests.
|
|
|
✅ |
The default redirect URI used for login redirect flow.
|
|
|
✅ |
The default scope used for authorization requests. If
|
|
|
✅ |
The default redirect URI used for the silent authentication flow.
|
|
✅ |
Manages the authorization transactions.
|
|
|
✅ |
Cache used to hold access tokens.
|
|
|
|
✅ |
Whether to use a refresh token rotation instead of the standard auth code grant flow with silent authentication. See Refresh Token (Rotation) Grant Type docs. The default is
|
|
|
✅ |
Whether to use silent authentication with iframe as a fallback when Default is
|
|
|
✅ |
Whether to serialize the in-memory token cache to session storage to allow persistence across page loads. This is somewhat less secure than leaving the cache in-memory but may be necessary in cross-domain auth contexts, i.e., when the client is served on a different domain from the auth server, because browsers block the cross-domain session cookie.
In these cases, the additional risk should be mitigated by also enabling refresh tokens ( Default is
|
|
|
✅ |
Whether to serialize the in-memory token cache to local storage to allow persistence across page loads. This is similar to Default is
|
|
|
✅ |
Determines whether a param indicating that the app should automatically redirect the user to login is enabled. This is used in cases where auto-login from the server is not possible due to needing third-party-cookies, which are blocked in most browsers by default. This param is usually not used unless refresh-token-rotation is also used. The param’s value is Default is
|
Handles parsing the callback parameters as part of the OAuth2 Authorization Code Grant (optionally) with PKCE flow. This flow is typically first initiated with a call to #loginWithRedirect.
AuthClient#handleRedirectCallback(url);
Parameter | Type | Required? | Description |
---|---|---|---|
|
|
✅ |
Browser URL with callback parameters |
The result from a login-with-redirect request.
This holds the state that should be validated in the app in the auth code grant flow: LoginRedirectResult.
LoginRedirectResult#appState
will usually be AuthAppState.
Gets an access token.
If #useRefreshTokens
is true
, then this will use the refresh token to get a new access token.
Else, it will use silent authentication in an iframe.
AuthClient#getAccessToken();
Checks if the user has a session and refresh the session by silently retrieving a token that pre-fills the token cache. This will suppress 'login_required' errors as these are recoverable by asking the user to login.
AuthClient#checkSession();
Fetches the user information from the auth server.
AuthClient#getUserInfo();
The authenticated user’s info: User.
Clears the authenticated user’s session with the authorization server. Upon a successful logout, redirects to the LogoutRedirectOptions#returnTo location.
AuthClient#logoutWithRedirect();
Redirects the user to change their password on the authorization server. Upon a successful change password, the user will be redirect back to the application using the provided ChangePasswordRedirectOptions#returnTo URL.
Note, the returnTo
location must be a valid redirect URI for the authorized client.
AuthClient#changePasswordWithRedirect();
Redirects the user to register on the authorization server. Upon a successful registration, the user will be redirect back to the application using the provided RegisterRedirectOptions#returnTo URL.
Note, the returnTo
location must be a valid redirect URI for the authorized client.
AuthClient#registerWithRedirect();
Returns whether or not we are able to determine that the user is authenticated. It checks to see if there is a cached token for the default client scope.
AuthClient#isAuthenticated();
Returns the latest known SessionExpiry for the default user scope. If no token is cached, this will return undefined.
AuthClient#getSessionExpiry();
Parameter | Type | Required? | Description |
---|---|---|---|
|
❌ |
Options for configuration the request to get the latest SessionExpiry for the user scope. |
The SessionExpiry or undefined if none.
Returns the identity claims for the latest AccessToken. Uses the scope provided within the GetIdentityClaimsOptions to retrieve a cached token’s IdentityClaims. If no scope is provided, the default scope will be used.
AuthClient#getIdentityClaims();
Parameter | Type | Required? | Description |
---|---|---|---|
|
❌ |
Configuration options for when building the URL for the request to get the IdentityClaims for an AccessToken. |
The IdentityClaims or undefined if none.
Method to use when logging in from an embedded form instead of redirecting to the auth server for in the Authentication Microservice’s configuration properties.
On the backend, broadleaf.auth.login.embedded.enabled
(global property) must be true
and the AuthorizationServer
being submitted to must have embeddedLoginEnabled
also set to true.
The request will return a one-time-password token that will be sent to retrieve an access token automatically.
AuthClient#loginWithCredentials(request, options);
Method to use when registering from an embedded form instead of redirecting to the auth server for Universal Login.
On the backend, broadleaf.auth.login.embedded.enabled
(global property) must be true
and the auth server being submitted to must have embeddedLoginEnabled
also set to true.
Note
|
The responding request may include a session cookie (signed JWT) if auto-login is enabled on the server. |
AuthClient#registerWithCredentials(request);
Parameter | Type | Required? | Description |
---|---|---|---|
|
✅ |
Represents a request to register a user with credentials for an embedded form as opposed to registering with a redirect for Universal Login. |
The new User.
Method to use when changing password from an embedded form instead of redirecting to the auth server for Universal Login.
On the backend, broadleaf.auth.login.embedded.enabled
(global property) must be true
and the auth server being submitted to must have embeddedLoginEnabled
also set to true.
AuthClient#changePasswordWithCredentials(request);
Method to use when requesting a reset password link from an embedded form instead of redirecting to the auth server for Universal Login.
On the backend, broadleaf.auth.login.embedded.enabled
(global property) must be true
and the auth server being submitted to must have embeddedLoginEnabled
also set to true.
AuthClient#requestResetPasswordLinkWithCredentials(request);
Method to use when resetting a password from an embedded form instead of redirecting to the auth server for Universal Login.
On the backend, broadleaf.auth.login.embedded.enabled
(global property) must be true
and the auth server being submitted to must have embeddedLoginEnabled
also set to true.
Note
|
The responding request may include a session cookie if auto-login is enabled on the server. |
AuthClient#resetPasswordWithCredentials(request);