Problem
App Check works fine in production mode, but in debug mode I get errors:
401: Firebase App Check token is invalid.
I tried two things:
- Generate a debug token using Firebase console.
- Generate a debug token in the App via inserting
<script>self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;</script>
intoindex.html
. And then adding that to in the Firebase console as a debug token. I also noticed that this way a new debug token is generated on each App restart.
Code
if (kReleaseMode) {
await FirebaseAppCheck.instance.activate(
webRecaptchaSiteKey: LIVE_TOKEN,
);
} else {
await FirebaseAppCheck.instance.activate(
webRecaptchaSiteKey: DEBUG_TOKEN,
);
}
Question
Using FlutterFire, what is the correct way to generate and use a debug token for App Check? Following the docs did not work for me.
Docs
https://firebase.google.com/docs/app-check/flutter/default-providers
https://firebase.flutter.dev/docs/app-check/debug-provider/#activating-the-debug-provider-web