-2

I'm using firebase_storage and firebase_app_check. I get the error in the following code.

await FirebaseAuth.instance.signInWithEmailAndPassword(email: 'foo@bar.com', password: '********');
FirebaseStorage.instance.ref('images/foo.png').putFile(file)

[firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.

I've added the debug secret token to the console and the debug version of the app works fine, however, if I run the release version of the app on a physical Android device I get the error. Why is that so?

AppCheck Settings:

enter image description here

Project Settings

I've uploaded both debug and release certificates on the Firebase Project Settings page.

enter image description here

iDecode
  • 22,623
  • 19
  • 99
  • 186

2 Answers2

1

One more time thanks to the Docs for not providing enough information.

For release mode, in my build.gradle(app):

implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta04'

I also need to add in my MainActivity.java:

FirebaseApp.initializeApp(this);
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
firebaseAppCheck.installAppCheckProviderFactory(SafetyNetAppCheckProviderFactory.getInstance());
iDecode
  • 22,623
  • 19
  • 99
  • 186
0

Please do one thing after adding SHA-1 and SHA-256 for release build Re download the google-services.json file and replace it with existing one in your project then do flutter clean and try to run release build and check.

Hardik Mehta
  • 2,195
  • 1
  • 11
  • 14