The Firebase AppCheck service interface.

Do not call this constructor directly. Instead, use firebase.appCheck().

Index

Methods

activate

getToken

  • getToken ( forceRefresh ? :  boolean ) : Promise < AppCheckTokenResult >
  • Get the current App Check token. Attaches to the most recent in-flight request if one is present. Returns null if no token is present and no token requests are in-flight.

    Parameters

    • Optional forceRefresh: boolean

      If true, will always try to fetch a fresh token. If false, will use a cached token if found in storage.

    Returns Promise<AppCheckTokenResult>

onTokenChanged

  • onTokenChanged ( observer { complete ?: ( ) => void ; error ?: ( error Error ) => void ; next : ( tokenResult AppCheckTokenResult ) => void } ) : Unsubscribe
  • Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes.

    Parameters

    • observer: { complete?: () => void; error?: (error: Error) => void; next: (tokenResult: AppCheckTokenResult) => void }

      An object with next, error, and complete properties. next is called with an AppCheckTokenResult whenever the token changes. error is optional and is called if an error is thrown by the listener (the next function). complete is unused, as the token stream is unending.

    Returns Unsubscribe

    A function that unsubscribes this listener.

  • onTokenChanged ( onNext ( tokenResult AppCheckTokenResult ) => void ,  onError ? :  ( error Error ) => void ,  onCompletion ? :  ( ) => void ) : Unsubscribe
  • Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes.

    Parameters

    • onNext: (tokenResult: AppCheckTokenResult) => void

      When the token changes, this function is called with aa AppCheckTokenResult.

    • Optional onError: (error: Error) => void

      Optional. Called if there is an error thrown by the listener (the onNext function).

        • Parameters

          Returns void

    • Optional onCompletion: () => void

      Currently unused, as the token stream is unending.

        • (): void
        • Returns void

    Returns Unsubscribe

    A function that unsubscribes this listener.

setTokenAutoRefreshEnabled

  • setTokenAutoRefreshEnabled ( isTokenAutoRefreshEnabled boolean ) : void
  • Parameters

    • isTokenAutoRefreshEnabled: boolean

      If true, the SDK automatically refreshes App Check tokens as needed. This overrides any value set during activate().

    Returns void