Using Firebase App Check is not working (debug)

7.5k views Asked by At

I am not able to settle this issue when implementing the new App Check feature from Firebase.

When uploading files to Firebase Storage it fails with an error

Caused by: java.io.IOException: { "error": { "code": 401, "message": "Firebase App Check token is invalid." }}

I already provided the debug secret just like what is in this documentation.

The debug apk was installed directly via USB debugging.

Note: I am using a physical device and enabled Enforce status on both Storage and Real-time database and it fails whenever I tried to do transaction like upload and the error above shows.

3

There are 3 answers

3
Ali Yar Khan On

Run the App on Physical device. I was facing the same issue and but when i run the app on a physical device it is gone! Ensure you main run app funtion is like this

This is the code docs have mentioned:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await FirebaseAppCheck.instance.activate(webRecaptchaSiteKey: 'recaptcha-v3-site-key');
  runApp(MyApp());
}
1
Rashid Kamal On

I have used a physical device, in my opinion, which is far better to use than an emulator. All you need is SHA 256 key and register your application in the safety net in project settings. To get SHA 256 key, just click on the Gradle tab in the leftmost corner in android studio. Click android folder within your application folder and run signiningReport. It will generate SHA 256 key in the terminal and copy it into the safety net. That's it.

0
abhi On

make sure to update all the Firebase related libraries first and try again. it shall work.