Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • AuthService

Implements

  • OnDestroy

Index

Constructors

constructor

Properties

Readonly error$

error$: Observable<Error> = this.errorSubject$.asObservable()

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

Readonly isAuthenticated$

isAuthenticated$: Observable<boolean> = this.isLoading$.pipe(filter((loading) => !loading),distinctUntilChanged(),concatMap(() => this.isAuthenticatedSubject$))

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.

Readonly isLoading$

isLoading$: Observable<boolean> = this.isLoadingSubject$.asObservable()

Emits boolean values indicating the loading state of the SDK.

Readonly user$

user$: Observable<any> = this.isAuthenticated$.pipe(filter((authenticated) => authenticated),distinctUntilChanged(),concatMap(() => this.auth0Client.getUser()))

Emits details about the authenticated user when isAuthenticated$ is true.

Methods

getAccessTokenSilently

  • getAccessTokenSilently(options?: GetTokenSilentlyOptions): Observable<string>
  • getAccessTokenSilently(options).subscribe(token => ...)

    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.

    If refresh tokens are used, the token endpoint is called directly with the 'refresh_token' grant. If no refresh token is available to make this call, the SDK falls back to using an iframe to the '/authorize' URL.

    This method may use a web worker to perform the token call if the in-memory cache is used.

    If an audience value is given to this function, the SDK always falls back to using an iframe to make the token exchange.

    Note that in all cases, falling back to an iframe requires access to the auth0 cookie, and thus will not work in browsers that block third-party cookies by default (Safari, Brave, etc).

    Parameters

    • Optional options: GetTokenSilentlyOptions

      The options for configuring the token fetch.

    Returns Observable<string>

getAccessTokenWithPopup

  • getAccessTokenWithPopup(options?: GetTokenWithPopupOptions): Observable<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

    • Optional options: GetTokenWithPopupOptions

    Returns Observable<string>

loginWithPopup

  • loginWithPopup(options?: PopupLoginOptions, config?: PopupConfigOptions): Observable<void>
  • 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

    • Optional options: PopupLoginOptions

      The login options

    • Optional config: PopupConfigOptions

      Configuration for the popup window

    Returns Observable<void>

loginWithRedirect

  • loginWithRedirect(options?: RedirectLoginOptions): Observable<void>
  • 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

    • Optional options: RedirectLoginOptions

      The login options

    Returns Observable<void>

logout

  • logout(options?: LogoutOptions): 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 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 Auth0.

    Parameters

    • Optional options: LogoutOptions

      The logout options

    Returns void

ngOnDestroy

  • ngOnDestroy(): void