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.6k stars 3.95k forks source link

🐛 [firebase_auth] Unclear 'internal error' returned on iOS when trying facebook credentials sign in against auth Emulator #6775

Closed Frank-D closed 3 years ago

Frank-D commented 3 years ago

Bug report

Describe the bug After user successful login against facebook (using 'flutter_facebook_auth: ^3.5.0'), next, when trying to create/sign in user in firebase auth (using 'firebase_core: ^1.4.0' & 'firebase_auth: ^3.0.1), I'm getting an "internal error" when testing on iOS simulator. This made me loose several hours of debugging and research, until I decide to test the exact same code using instead an android emulator, and that time, the underlying error message was not absorbed by firebase library but displayed to me in the [vs code] console, a very clear message telling me that facebook sign in is not supported when using firebase auth emulator. I was then able to research the right thing online from firebase emulator auth documentation, and confirm that limitation within minutes (ref.: https://firebase.google.com/docs/emulator-suite/connect_auth#testing_idp_flows_with_manual_credential_retrieval).

Bottom line, I'm not sure why iOS and Android are not returning the same error message, after executing the exact same code, but clearly, on android the message is clear and helps devs know what's going on, versus on iOS devs may loose many hours by not understand from such abstract err message what's going on.

Steps to reproduce

Steps to reproduce the behavior:

Running the following flutter lines of code on "iOS simulator" (in my case: "iPhone 12 Pro Max"):

  1. final LoginResult result = await FacebookAuth.instance.login(); // from package: flutter_facebook_auth: ^3.5.0
  2. final OAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(result.accessToken!.token); // from packages: 'firebase_core: ^1.4.0' & 'firebase_auth: ^3.0.1
  3. userCredential = await _firebaseAuth.signInWithCredential(facebookAuthCredential); // will throw exception with message below...

ACTUAL UNCLEAR iOS ERROR MESSAGE:

"flutter: [firebase_auth/internal-error] An internal error has occurred, print and inspect the error details for more information."

Expected behavior

The same error as per when running the exact same code against an Android Emulator should be returned when running on iOS simulator.

EXPECTED CLEAR ERROR MESSAGE (this is the error message returned for the exact same code, but running on Android emulator, in my case, on "Pixel 3a API 30 (Android 11.0)"):

"I/flutter ( 9624): [firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ The Auth Emulator does not support facebook.com sign-in with credentials. ]"

Sample project

Please refer to the "Steps to reproduce" section, where I've put the only 3 lines of code to reproduce the error.


Additional context

n.a.


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, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-CA) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.2) [✓] VS Code (version 1.58.0) [✓] Connected device (2 available) • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.13.4 Flutter SDK 2.2.3 freetime 1.0.0+1 dependencies: - auth_service_api 1.0.0 [flutter equatable meta] - awesome_dialog 2.1.0 [flutter simple_animations flare_flutter] - bloc 7.0.0 [meta] - cloud_firestore 2.2.2 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.2 - easy_localization 3.0.0 [flutter shared_preferences intl args path easy_logger flutter_localizations] - equatable 2.0.3 [collection meta] - expandable_bottom_bar 2.0.2 [flutter] - firebase_auth_service 1.0.0 [flutter equatable firebase_auth firebase_core flutter_facebook_auth google_sign_in meta auth_service_api] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_bloc 7.0.0 [flutter bloc provider] - flutter_easyloading 3.0.0 [flutter flutter_spinkit] - fluttertoast 8.0.7 [flutter flutter_web_plugins] - font_awesome_flutter 9.0.0 [flutter] - get_it 7.1.4 [async collection] - google_fonts 2.1.0 [flutter http path_provider crypto] - hydrated_bloc 7.0.0 [bloc hive meta synchronized] - meta 1.3.0 - modal_bottom_sheet 2.0.0 [flutter] - pedantic 1.11.0 - reactive_forms 10.0.3 [flutter intl] - rflutter_alert 2.0.2 [flutter] - snack 2.0.0 [flutter] - top_snackbar_flutter 1.0.0 [flutter] - vrouter 1.1.0+22 [flutter simple_url_handler path_to_regexp url_strategy js url_launcher move_to_background] transitive dependencies: - args 2.0.0 - async 2.7.0 [collection meta] - characters 1.1.0 - charcode 1.2.0 - clock 1.1.0 - cloud_firestore_platform_interface 5.1.2 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.1.2 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - crypto 3.0.0 [collection typed_data] - easy_logger 0.0.2 [flutter] - ffi 1.0.0 - file 6.1.0 [meta path] - firebase_auth 3.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_auth_platform_interface 6.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - flare_flutter 3.0.0 [collection flutter meta] - flutter_facebook_auth 3.5.0 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web] - flutter_facebook_auth_platform_interface 2.7.0 [flutter plugin_platform_interface] - flutter_facebook_auth_web 2.6.0+2 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_spinkit 5.0.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - google_sign_in 5.0.7 [flutter google_sign_in_platform_interface google_sign_in_web meta] - google_sign_in_platform_interface 2.0.1 [flutter meta quiver] - google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - hive 2.0.0 [meta crypto] - http 0.13.1 [http_parser meta path pedantic] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - js 0.6.3 - matcher 0.12.10 [stack_trace] - move_to_background 1.0.2 [flutter] - nested 1.0.0 [flutter] - path 1.8.0 - path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.0 [path_provider_platform_interface meta path flutter ffi win32] - path_to_regexp 0.4.0 - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.1 [file path platform] - provider 5.0.0 [collection flutter nested] - quiver 3.0.1 [matcher] - shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows] - simple_animations 3.1.1 [flutter supercharged pedantic] - simple_url_handler 1.0.0 [flutter] - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - stack_trace 1.10.0 [path] - string_scanner 1.1.0 [charcode source_span] - supercharged 2.0.0 [supercharged_dart flutter] - supercharged_dart 2.0.0 - synchronized 3.0.0 - term_glyph 1.2.0 - typed_data 1.3.0 [collection] - url_launcher 6.0.3 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins] - url_launcher_windows 2.0.0 [flutter] - url_strategy 0.2.0 [flutter_web_plugins] - vector_math 2.1.0 - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] ```

darshankawar commented 3 years ago

@Frank-D Thanks for the detailed report and digging in to identify the ios specific issue. As the error says:

"flutter: [firebase_auth/internal-error] An internal error has occurred, print and inspect the error details for more information."

I tend to think this could be specific to simulators and seem to be coming from firebase-sdk. Please see this similar issue open talking about same case, https://github.com/FirebaseExtended/flutterfire/issues/5244

I do agree that all error details should be made available to Dart for proper error handling in both platforms and should be consistent, but this is something that need to be fixed at firebase-sdk level and not at the firebase_auth plugin level.

I am going ahead and labeling it.

Cc: @russellwheatley Do you think this issue need to be separately logged in https://github.com/firebase/firebase-tools/issues or can it be tracked under https://github.com/FirebaseExtended/flutterfire/issues/5244 and subsequently https://github.com/firebase/firebase-tools/issues/3424 ?