firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

🐛 [firebase_auth] [firebase_auth/unknown] An internal error has occurred. [ Failed to generate/retrieve public encryption key for Generic IDP flow. ] #11571

Closed eli1stark closed 1 year ago

eli1stark commented 1 year ago

Bug report

Describe the bug

Apple sign-in stopped working on certain Android devices after 4.6.3 version. Same firebase project, same build and same apple account credentials. And for one android phone it works and for other it doesn't. The one that I used had Android 10 and apple sign-in didn't work, then I tried phone with Android 12 and apple sign-in worked as expected. The same android device that didn't work, worked fine for other firebase projects.

I tried v4.7.3 and v4.9.0 (the latest one), all of these versions have the issue for my 1st android phone (with android 10) but not for 2nd android phone (with android 12).

Unfortunately, I can't test v4.6.3 anymore because it throws:

../../.pub-cache/hosted/pub.dev/firebase_auth-4.6.3/lib/src/firebase_auth.dart:427:44: Error: The argument type 'bool?' can't be assigned to the parameter type 'bool' because 'bool?' is nullable and 'bool' isn't.

Steps to reproduce

The code I use to sign-in:

final provider = AppleAuthProvider();
await FirebaseAuth.instance.signInWithProvider(provider);

I can reproduce it consistently for one Firebase project. I have development, staging and production environments which results in 3 separate firebase projects. It works for development and staging project for both devices but not for production, production only works for the device with android 12.

It can easily seem like misconfiguration issue but if it was the case then 2nd android device (with android 12) wouldn't work. And I 100% sure it worked in the past for the 1st device.

To elaborate a bit more, when I call signInWithProvider, device with android 12 opens browser and starts apple sign in, for device with android 10 even browser is not opened, error is thrown immediately, however browser is opened for other environments (development and staging).

Another interesting fact is that apple sign-in for production env on device with android 10 works fine in Debug mode. So this issue is only reproducible in release mode for certain android phones and in certain firebase projects. Development and staging envs work okay for both devices in debug and release mode, signed by Google Play.

I know that without complete reproducible example this won't be likely resolved, I'm more opening the issue to raise awareness to this and if someone happened to encounter it maybe my information will be helpful in the search of reproducible example and the root of the problem.

Expected behavior

Apple sign-in should not throw error.


Additional context

Similar closed issues that I found:

11360 - this issue describes similar case, for some devices it works and for some it doesn't work.

7066 - this issue states that recreating firebase project resolved the issue but this is not a proper fix.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.6, on macOS 13.3.1 22E772610a darwin-arm64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] VS Code (version 1.81.1) [✓] Connected device (2 available) [✓] Network resources ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` firebase_core: 2.15.1 firebase_crashlytics: 3.3.5 firebase_analytics: 10.4.5 firebase_dynamic_links: 5.3.5 firebase_app_check: 0.1.5+2 firebase_auth: 4.7.3 cloud_firestore: 4.9.1 cloud_functions: 4.4.0 ```

danagbemava-nc commented 1 year ago

Hi @eli1stark, what are the two devices you are using in your testing?

Can you also try https://stackoverflow.com/a/77070245 to see if it helps?

eli1stark commented 1 year ago

The device that didn't work is Xiaomi Mi 9 Lite and the device that worked is Motorola Moto G Power (2022).

Steps:

  1. I set the following in the manifest file as mentioned in the stack overflow comment:

      android:allowBackup="false"
      android:fullBackupContent="false"
  2. I published the build with changes to Google Play.

  3. I uninstalled the app and then installed the new update and apple sign-in worked.

Thank you for your help, who would have guessed.

danagbemava-nc commented 1 year ago

Glad that helped.

Closing this as solved.