FirebaseAppCheck

public abstract class FirebaseAppCheck implements InteropAppCheckTokenProvider


Summary

Nested types

Public constructors

Public methods

abstract void

Registers an AppCheckListener to changes in the token state.

abstract @NonNull Task<AppCheckToken>
getAppCheckToken(boolean forceRefresh)

Requests a Firebase App Check token.

static @NonNull FirebaseAppCheck

Gets the default instance of FirebaseAppCheck.

static @NonNull FirebaseAppCheck

Gets the instance of FirebaseAppCheck associated with the given FirebaseApp instance.

abstract @NonNull Task<AppCheckToken>

Requests a Firebase App Check token.

abstract void

Installs the given AppCheckProviderFactory, overwriting any that were previously associated with this FirebaseAppCheck instance.

abstract void
installAppCheckProviderFactory(
    @NonNull AppCheckProviderFactory factory,
    boolean isTokenAutoRefreshEnabled
)

Installs the given AppCheckProviderFactory, overwriting any that were previously associated with this FirebaseAppCheck instance.

abstract void

Unregisters an AppCheckListener to changes in the token state.

abstract void
setTokenAutoRefreshEnabled(boolean isTokenAutoRefreshEnabled)

Sets the isTokenAutoRefreshEnabled flag.

Public constructors

FirebaseAppCheck

public FirebaseAppCheck()

Public methods

addAppCheckListener

public abstract void addAppCheckListener(@NonNull FirebaseAppCheck.AppCheckListener listener)

Registers an AppCheckListener to changes in the token state. This method should be used ONLY if you need to authorize requests to a non-Firebase backend. Requests to Firebase backends are authorized automatically if configured.

getAppCheckToken

public abstract @NonNull Task<AppCheckTokengetAppCheckToken(boolean forceRefresh)

Requests a Firebase App Check token. This method should be used ONLY if you need to authorize requests to a non-Firebase backend. Requests to Firebase backends are authorized automatically if configured.

If your non-Firebase backend exposes a sensitive or expensive endpoint that has low traffic volume, consider protecting it with Replay Protection. In this case, use getLimitedUseAppCheckToken instead to obtain a limited-use token.

getInstance

public static @NonNull FirebaseAppCheck getInstance()

Gets the default instance of FirebaseAppCheck.

getInstance

public static @NonNull FirebaseAppCheck getInstance(@NonNull FirebaseApp firebaseApp)

Gets the instance of FirebaseAppCheck associated with the given FirebaseApp instance.

getLimitedUseAppCheckToken

public abstract @NonNull Task<AppCheckTokengetLimitedUseAppCheckToken()

Requests a Firebase App Check token. This method should be used ONLY if you need to authorize requests to a non-Firebase backend.

Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints that are protected with Replay Protection. This method does not affect the token generation behavior of the getAppCheckToken method.

installAppCheckProviderFactory

public abstract void installAppCheckProviderFactory(@NonNull AppCheckProviderFactory factory)

Installs the given AppCheckProviderFactory, overwriting any that were previously associated with this FirebaseAppCheck instance. Any AppCheckTokenListeners attached to this FirebaseAppCheck instance will be transferred from existing factories to the newly installed one.

Automatic token refreshing will only occur if the global isDataCollectionDefaultEnabled flag is set to true. To allow automatic token refreshing for Firebase App Check without changing the isDataCollectionDefaultEnabled flag for other Firebase SDKs, use installAppCheckProviderFactory instead or call setTokenAutoRefreshEnabled after installing the factory.

installAppCheckProviderFactory

public abstract void installAppCheckProviderFactory(
    @NonNull AppCheckProviderFactory factory,
    boolean isTokenAutoRefreshEnabled
)

Installs the given AppCheckProviderFactory, overwriting any that were previously associated with this FirebaseAppCheck instance. Any AppCheckTokenListeners attached to this FirebaseAppCheck instance will be transferred from existing factories to the newly installed one.

Automatic token refreshing will only occur if the isTokenAutoRefreshEnabled field is set to true. To use the global isDataCollectionDefaultEnabled flag for determining automatic token refreshing, call installAppCheckProviderFactory instead.

removeAppCheckListener

public abstract void removeAppCheckListener(
    @NonNull FirebaseAppCheck.AppCheckListener listener
)

Unregisters an AppCheckListener to changes in the token state.

setTokenAutoRefreshEnabled

public abstract void setTokenAutoRefreshEnabled(boolean isTokenAutoRefreshEnabled)

Sets the isTokenAutoRefreshEnabled flag.