@auth0/auth0-angular
    Preparing search index...

    Class AuthService<TAppState>

    Type Parameters

    Implements

    • OnDestroy
    Index

    Constructors

    Properties

    appState$: Observable<TAppState> = ...

    Emits the value (if any) that was passed to the loginWithRedirect method call but only after handleRedirectCallback is first called

    error$: Observable<Error> = ...

    Emits errors that occur during login, or when checking for an active session on startup.

    idTokenClaims$: Observable<IdToken | null | undefined> = ...

    Emits ID token claims when authenticated, or null if not authenticated.

    isAuthenticated$: Observable<boolean> = ...

    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.

    isLoading$: Observable<boolean> = ...

    Emits boolean values indicating the loading state of the SDK.

    user$: Observable<User | null | undefined> = ...

    Emits details about the authenticated user, or null if not authenticated.

    Methods

    • generateDpopProof(params).subscribe(proof => ...)
      

      Generates a DPoP (Demonstrating Proof-of-Possession) proof JWT. This proof is used to bind access tokens to a specific client, providing an additional layer of security for token usage.

      Parameters

      • params: { accessToken: string; method: string; nonce?: string; url: string }

        Configuration for generating the DPoP proof

        • accessToken: string

          The access token to bind to the proof

        • method: string

          The HTTP method (e.g., 'GET', 'POST')

        • Optionalnonce?: string

          Optional DPoP nonce from the authorization server

        • url: string

          The URL of the resource server endpoint

      Returns Observable<string>

      An Observable that emits the generated DPoP proof as a JWT string.

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

      Parameters

      Returns Observable<string | undefined>

    • getDpopNonce(id).subscribe(nonce => ...)
      

      Gets the DPoP nonce for the specified domain or the default domain. The nonce is used in DPoP proof generation for token binding.

      Parameters

      • Optionalid: string

        Optional identifier for the domain. If not provided, uses the default domain.

      Returns Observable<string | undefined>

      An Observable that emits the DPoP nonce string or undefined if not available.

    • handleRedirectCallback(url).subscribe(result => ...)
      

      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.

      Calling this method also refreshes the authentication and user states.

      Parameters

      • Optionalurl: string

        The URL to that should be used to retrieve the state and code values. Defaults to window.location.href if not given.

      Returns Observable<
          RedirectLoginResult<TAppState>
          | ConnectAccountRedirectResult<TAppState>,
      >

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

      Parameters

      Returns Observable<void>

    • logout();
      

      Clears the application session and performs a redirect to /v2/logout, using the parameters provided as arguments, to clear the Auth0 session. If the federated option is specified it also clears the Identity Provider session. If the openUrl option is set to false, it only clears the application session. It is invalid to set both the federated to true and openUrl to false, and an error will be thrown if you do. Read more about how Logout works at Auth0.

      Parameters

      Returns Observable<void>

    • setDpopNonce(nonce, id).subscribe(() => ...)
      

      Sets the DPoP nonce for the specified domain or the default domain. This is typically used after receiving a new nonce from the authorization server.

      Parameters

      • nonce: string

        The DPoP nonce value to set.

      • Optionalid: string

        Optional identifier for the domain. If not provided, uses the default domain.

      Returns Observable<void>

      An Observable that completes when the nonce is set.