Retrieves API-specific credentials.
The identifier of the API for which to get credentials.
Optionalscope: stringThe scopes to request for the new access token.
OptionalminTtl: numberThe minimum time-to-live (in seconds) required for the access token. If the token expires sooner, a refresh will be attempted.
Optionalparameters: Record<string, any>Additional parameters to send during the token refresh request.
A promise that resolves with the API credentials.
Removes cached credentials for a specific audience.
The identifier of the API for which to clear credentials.
A promise that resolves when the credentials are cleared.
Initiates the web-based authentication flow.
Optionalparameters: WebAuthorizeParametersThe parameters to send to the /authorize endpoint.
Optionaloptions: NativeAuthorizeOptionsPlatform-specific options to customize the authentication experience.
A promise that resolves with the user's credentials upon successful authentication.
Clears the user's session and logs them out.
Optionalparameters: ClearSessionParametersThe parameters to send to the /v2/logout endpoint.
Optionaloptions: NativeClearSessionOptionsPlatform-specific options to customize the logout experience.
A promise that resolves when the session has been cleared.
Saves the user's credentials.
The credentials to save.
A promise that resolves when the credentials have been saved.
Retrieves the stored credentials, refreshing them if necessary.
Optionalscope: stringThe scopes to request for the new access token (used during refresh).
OptionalminTtl: numberThe minimum time-to-live (in seconds) required for the access token.
Optionalparameters: Record<string, unknown>Additional parameters to send during the refresh request.
OptionalforceRefresh: booleanIf true, forces a refresh of the credentials.
A promise that resolves with the user's credentials.
Clears the user's credentials without clearing their web session and logs them out.
A promise that resolves when the credentials have been cleared.
Checks if a valid, non-expired set of credentials exists in storage. This is a quick, local check and does not perform a network request.
OptionalminTtl: numberThe minimum time-to-live (in seconds) required for the access token to be considered valid. Defaults to 0.
A promise that resolves with true if valid credentials exist, false otherwise.
Cancels the ongoing web authentication process. This works only on iOS. On other platforms, it will resolve without performing an action.
Authenticates a user with their username and password.
The parameters for the password-realm grant.
A promise that resolves with the user's credentials.
Creates a new user in a database connection.
The parameters for creating the new user.
A promise that resolves with the new user's profile information.
Resets the user's password.
The parameters for resetting the password.
A promise that resolves when the password has been reset.
Exchanges an authorization code for tokens. This is useful in advanced scenarios where you manage the code flow manually.
The parameters containing the authorization code and verifier.
A promise that resolves with the user's credentials.
Exchanges an authorization code for native social tokens.
The parameters containing the authorization code and verifier.
A promise that resolves with the user's credentials.
Exchanges an external identity provider token for Auth0 tokens. Uses RFC 8693 OAuth 2.0 Token Exchange specification.
The token exchange parameters.
A promise that resolves with the user's Auth0 credentials.
Sends a verification code to the user's email.
The parameters for sending the email code.
Authorizes a user with their email.
The parameters for email authorization.
A promise that resolves with the user's credentials.
/**
The parameters for sending the SMS code. *
Authorizes a user with their SMS.
The parameters for SMS authorization.
A promise that resolves with the user's credentials.
Sends a multifactor challenge to the user.
The parameters for the multifactor challenge.
A promise that resolves when the challenge has been sent.
Authorizes a user with out-of-band (OOB) authentication.
The parameters for OOB authorization.
A promise that resolves with the user's credentials.
Authorizes a user with a one-time password (OTP).
The parameters for OTP authorization.
A promise that resolves with the user's credentials.
Authorizes a user with a recovery code.
The parameters for recovery code authorization.
A promise that resolves with the user's credentials.
Generates DPoP headers for making authenticated requests to custom APIs. This method creates the necessary HTTP headers (Authorization and DPoP) to securely bind the access token to a specific API request.
Parameters including the URL, HTTP method, access token, and token type.
A promise that resolves to an object containing the required headers.
const credentials = await getCredentials();
if (credentials.tokenType === 'DPoP') {
const headers = await getDPoPHeaders({
url: 'https://api.example.com/data',
method: 'GET',
accessToken: credentials.accessToken,
tokenType: credentials.tokenType
});
const response = await fetch('https://api.example.com/data', { headers });
}
Obtains session transfer credentials for performing Native to Web SSO.
Optionalparameters: Record<string, any>Optional additional parameters to pass to the token exchange.
Optionalheaders: Record<string, string>Optional additional headers to include in the token exchange request. iOS only - this parameter is ignored on Android.
A promise that resolves with the session transfer credentials.
This method exchanges the stored refresh token for a session transfer token
that can be used to authenticate in web contexts without requiring the user
to log in again. The session transfer token can be passed as a cookie or
query parameter to the /authorize endpoint to establish a web session.
Session transfer tokens are short-lived and expire after a few minutes. Once expired, they can no longer be used for web SSO.
If Refresh Token Rotation is enabled, this method will also update the stored credentials with new tokens (ID token and refresh token) returned from the token exchange.
Platform specific: This method is only available on native platforms (iOS/Android). On web, it will throw an error.
// Get session transfer credentials
const ssoCredentials = await getSSOCredentials();
// Option 1: Use as a cookie (recommended)
const cookie = `auth0_session_transfer_token=${ssoCredentials.sessionTransferToken}; path=/; domain=.yourdomain.com; secure; httponly`;
document.cookie = cookie;
window.location.href = `https://yourdomain.com/authorize?client_id=${clientId}&...`;
// Option 2: Use as a query parameter
const authorizeUrl = `https://yourdomain.com/authorize?session_transfer_token=${ssoCredentials.sessionTransferToken}&client_id=${clientId}&...`;
window.location.href = authorizeUrl;
Exchanges a refresh token for session transfer credentials via the Authentication API.
The parameters containing the refresh token to exchange.
A promise that resolves with the session transfer credentials.
This method calls the Auth0 /oauth/token endpoint directly to exchange a refresh token
for a session transfer token. Unlike getSSOCredentials() which uses the Credentials Manager,
this method is intended for apps that manage their own tokens.
Platform specific: This method is only available on native platforms (iOS/Android). On web, it will throw an error.
The contract for the value provided by the Auth0Context. This is the interface that developers will interact with when using the
useAuth0hook.