Options
All
  • Public
  • Public/Protected
  • All
Menu

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE.

Hierarchy

  • Auth0Client

Index

Constructors

constructor

Methods

getIdTokenClaims

  • const claims = await auth0.getIdTokenClaims();

    Returns all claims from the id_token if available.

    Parameters

    • Default value options: getIdTokenClaimsOptions = {audience: this.options.audience || 'default',scope: this.options.scope || this.DEFAULT_SCOPE}

    Returns Promise<IdToken>

getTokenSilently

  • const token = await auth0.getTokenSilently(options);

    If there's a valid token stored, return it. Otherwise, opens an iframe 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.

    Parameters

    • Default value options: GetTokenSilentlyOptions = {audience: this.options.audience,scope: this.options.scope || this.DEFAULT_SCOPE,ignoreCache: false}

    Returns Promise<any>

getTokenWithPopup

  • const token = await auth0.getTokenWithPopup(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.

    Parameters

    Returns Promise<string>

getUser

  • const user = await auth0.getUser();

    Returns the user information if available (decoded from the id_token).

    Parameters

    • Default value options: GetUserOptions = {audience: this.options.audience || 'default',scope: this.options.scope || this.DEFAULT_SCOPE}

    Returns Promise<any>

handleRedirectCallback

  • After the browser redirects back to the callback page, call handleRedirectCallback to handle success and error responses from Auth0. If the response is successful, results will be valid according to their expiration times.

    Returns Promise<RedirectLoginResult>

isAuthenticated

  • isAuthenticated(): Promise<boolean>
  • const isAuthenticated = await auth0.isAuthenticated();

    Returns true if there's valid information stored, otherwise returns false.

    Returns Promise<boolean>

loginWithPopup

  • await auth0.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.

    Parameters

    Returns Promise<void>

loginWithRedirect

  • await auth0.loginWithRedirect(options);

    Performs a redirect to /authorize using the parameters provided as arguments. Random and secure state and nonce parameters will be auto-generated.

    Parameters

    Returns Promise<void>

logout