Skip to content

Bug: SDK is still asking for debug token even if it's already correctly configured. #6967

@webbertakken

Description

@webbertakken

Describe your environment

  • Operating System version: Win 11
  • Browser version: Chrome Version 108.0.5359.126 (Official Build) (64-bit)
  • Firebase SDK version: 9.15.0
  • Firebase Product: App Check

Describe the problem

When filling the global.FIREBASE_APPCHECK_DEBUG_TOKEN parameter before initialising appCheck, you still see the message about having to fill it - even though it already works and you have no steps left to perform.

Example:

global.FIREBASE_APPCHECK_DEBUG_TOKEN = process.env.REACT_APP_FIREBASE_APP_CHECK_TOKEN
console.log(typeof global.FIREBASE_APPCHECK_DEBUG_TOKEN) // it is indeed set ✅
initializeAppCheck(app, {
  provider: new ReCaptchaV3Provider('some key'),
  isTokenAutoRefreshEnabled: true,
})

Steps to reproduce:

  • Follow this guide: https://firebase.google.com/docs/app-check/web/debug-provider
  • Open the app in the browser (dev mode) and find the message reading App Check debug token: ${token}. You will need to add it to your app's App Check settings in the Firebase console for it to work.
  • Pass the token to global.FIREBASE_APPCHECK_DEBUG_TOKEN and verify that it is successfully passed in.
  • Note that you still see the message about needing to add it (even though you already did correctly - the reason being that the message is always shown in debug mode)

Relevant Code:

It's always logged when debug mode is enabled, even when correctly configured.

See packages/app-check/src/api.ts:77:

  // is called in debug mode.
  if (isDebugMode()) {
    // Do not block initialization to get the token for the message.
    void getDebugToken().then(token =>
      // Not using logger because I don't think we ever want this accidentally hidden.
      console.log(
        `App Check debug token: ${token}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`
      )
    );
  }

Debug mode is always enabled when it's set. So both initially when true, but also when set to the actual token.

Thank you for you consideration.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions