flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

Android Emulator cannot access Firebase with App Check in Enforcement mode

Open lukertaylor opened this issue 3 years ago • 5 comments

Discussed in https://github.com/firebase/flutterfire/discussions/9284

Originally posted by lukertaylor August 1, 2022 Hello,

I have set-up App Check and followed the instructions (https://firebase.google.com/docs/app-check/android/debug-provider#kotlin+ktx_1) to successfully generate debug secrets on a physical Android device and the Android Emulator.

After installing the Debug Tokens in the Android Firebase app, the physical Android device works fine, but the Android Emulator cannot access Firestore:

/Firestore(): (24.2.1) [WriteStream]: () Stream closed with status: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}. W/Firestore(): (24.2.1) [Firestore]: Write failed at [path removed] 3: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null} E/flutter (): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

Is there a workaround? Or can I only debug on a physical Android device?

Thank you for any help received.

Luke

lukertaylor avatar Aug 03 '22 05:08 lukertaylor

I have found a workaround, which is to only load the App Check plug-in when building in release mode:

if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }

lukertaylor avatar Aug 03 '22 06:08 lukertaylor

@lukertaylor Currently it seems the app_check only works on real device and not on emulators. See this issue comment and see if it helps in your case.

darshankawar avatar Aug 03 '22 08:08 darshankawar

@darshankawar I found a different, and much simpler, workaround that I thought others might find helpful.

lukertaylor avatar Aug 03 '22 15:08 lukertaylor

@lukertaylor Can you also try this solution and see if it helps ?

darshankawar avatar Aug 09 '22 08:08 darshankawar

@darshankawar sorry but that isn't helpful. I am not using a Cloud Function.

I posted the issue and a workaround.

lukertaylor avatar Aug 10 '22 05:08 lukertaylor

I was able to get it to work using a MethodChannel: https://stackoverflow.com/a/73330541/5066615

rohan20 avatar Aug 12 '22 07:08 rohan20

I have found a workaround, which is to only load the App Check plug-in when building in release mode:

if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }

I guess your app will stop working as soon as you enable the AppCheck in the Firebase Console, since the backend will expect the token.

duduBaiao avatar Aug 17 '22 12:08 duduBaiao

No that is not the case. As long as the debug token has been registered.

On Wed, 17 Aug 2022, 14:36 Eduardo Baião, @.***> wrote:

I have found a workaround, which is to only load the App Check plug-in when building in release mode:

if (kReleaseMode) { await FirebaseAppCheck.instance.activate(); }

I guess your app will stop working as soon as you enable the AppCheck in the Firebase Console, since the backend will expect the token.

— Reply to this email directly, view it on GitHub https://github.com/firebase/flutterfire/issues/9291#issuecomment-1217952349, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIAQOOMDN2S5SRJL2WESGLVZTMEXANCNFSM55NQ7D6A . You are receiving this because you were mentioned.Message ID: @.***>

lukertaylor avatar Oct 11 '22 07:10 lukertaylor

This shouldn't be an issue now you can set whatever provider you wish on android i.e. debug provider.

russellwheatley avatar May 24 '23 13:05 russellwheatley