Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_auth]: Email is not returned when calling signInWithCredential with Google Credentials #13467

Open
1 task done
gurgenAya opened this issue Oct 7, 2024 · 9 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. plugin: auth type: bug Something isn't working

Comments

@gurgenAya
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Auth

Which platforms are affected?

Android, iOS

Description

When changing the Firebase Auth setting User account linking to Create multiple accounts for each identity provider from Firebase Console, the Auth signInWithCredential behavior is getting changed.

UserCredential.user.email is null in that case, however GoogleUser info contains the email field.

Reproducing the issue

Make sure in Firebase Console -> Authentication -> Setting -> User account linking is set to Create multiple accounts for each identity provider.

Sign in with Google and use Google provider to signInWithCredential.

Code Example:

  /// Signs in the user with Google.
  ///
  /// Returns a [UserCredential] if the sign-in is successful.
  Future<UserCredential?> signInWithGoogle() async {
    final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

    // Here email is available
    print(googleUser?.email);

    final GoogleSignInAuthentication? googleAuth =
        await googleUser?.authentication;

    if (googleAuth != null) {
      final OAuthCredential credential = GoogleAuthProvider.credential(
        accessToken: googleAuth.accessToken,
        idToken: googleAuth.idToken,
      );

      final credentials =
          await FirebaseAuth.instance.signInWithCredential(credential);

      // Here email is null
      print(credentials.user?.email);

      return credentials;
    }
    return null;
  }

Repeat the same test with User account linking set to Link accounts that use the same email and see that email is available in both checkpoints.

Firebase Core version

2.42.2

Flutter Version

3.22.2

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.4.3
Flutter SDK 3.22.2
drivery 1.0.0+12

dependencies:
- bloc 8.1.4 [meta]
- canopas_country_picker 0.0.9 [flutter]
- cloud_firestore 4.14.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- country_flags 3.0.0 [collection flutter jovial_svg]
- crypto 3.0.5 [typed_data]
- cupertino_icons 1.0.8
- device_info_plus 10.1.2 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- dio 5.6.0 [async http_parser meta path dio_web_adapter]
- equatable 2.0.5 [collection meta]
- firebase_auth 4.16.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 2.24.2 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 14.7.10 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_bloc 8.1.6 [bloc flutter provider]
- flutter_dotenv 5.1.0 [flutter]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_svg 2.0.10+1 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- flutter_verification_code 1.1.7 [flutter]
- get_it 7.7.0 [async collection meta]
- google_fonts 6.2.1 [flutter http path_provider crypto]
- google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- http 1.2.2 [async http_parser meta web]
- intl 0.19.0 [clock meta path]
- intl_phone_number_input 0.7.4 [flutter libphonenumber_plugin equatable collection]
- ipwhois 1.1.0 [http]
- lottie 3.1.2 [archive flutter http path vector_math]
- package_info_plus 8.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- phone_form_field 9.2.5 [flutter flutter_localizations intl flutter_country_selector circle_flags phone_numbers_parser]
- pinput 5.0.0 [flutter universal_platform]
- purchases_flutter 8.1.0 [flutter freezed_annotation json_annotation]
- reactive_forms 17.0.1 [flutter flutter_localizations intl]
- shared_preferences 2.3.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- sign_in_with_apple 6.1.2 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web]
- url_launcher 6.3.0 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]

dev dependencies:
- flutter_lints 3.0.2 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]

transitive dependencies:
- _flutterfire_internals 1.3.16 [collection firebase_core firebase_core_platform_interface flutter meta]
- archive 3.6.1 [crypto path]
- args 2.5.0
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- circle_flags 5.0.0 [flutter flutter_svg]
- clock 1.1.1
- cloud_firestore_platform_interface 6.1.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.9.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.18.0
- convert 3.1.1 [typed_data]
- device_info_plus_platform_interface 7.0.1 [flutter meta plugin_platform_interface]
- diacritic 0.1.5
- dio_web_adapter 2.0.0 [dio http_parser meta web]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.0 [meta path]
- firebase_auth_platform_interface 7.0.9 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.8.13 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta]
- firebase_core_platform_interface 5.2.1 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.10.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 4.5.18 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.5.18 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter_country_selector 1.0.11 [flutter flutter_localizations intl diacritic circle_flags phone_numbers_parser]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- freezed_annotation 2.4.4 [collection json_annotation meta]
- google_identity_services_web 0.3.1+4 [meta web]
- google_sign_in_android 6.1.28 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.7.7 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.4.5 [flutter plugin_platform_interface]
- google_sign_in_web 0.12.4+2 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- jovial_misc 0.8.5 [pointycastle async collection convert meta]
- jovial_svg 1.1.22 [xml collection args vector_math jovial_misc http meta flutter]
- js 0.6.7 [meta]
- json_annotation 4.9.0 [meta]
- leak_tracker 10.0.4 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.3 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- libphonenumber_platform_interface 0.4.2 [flutter plugin_platform_interface]
- libphonenumber_plugin 0.3.3 [flutter flutter_web_plugins libphonenumber_platform_interface libphonenumber_web]
- libphonenumber_web 0.3.2 [flutter flutter_web_plugins js libphonenumber_platform_interface]
- lints 3.0.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.8.0 [collection]
- meta 1.12.0
- nested 1.0.0 [flutter]
- package_info_plus_platform_interface 3.0.1 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_parsing 1.0.1 [vector_math meta]
- path_provider 2.1.4 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.10 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.0 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- petitparser 6.0.2 [meta]
- phone_numbers_parser 8.3.0 [meta]
- platform 3.1.5
- plugin_platform_interface 2.1.8 [meta]
- pointycastle 3.9.1 [collection convert js]
- provider 6.1.2 [collection flutter nested]
- shared_preferences_android 2.3.2 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.2 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sign_in_with_apple_platform_interface 1.1.0 [flutter plugin_platform_interface meta]
- sign_in_with_apple_web 2.1.0 [flutter flutter_web_plugins sign_in_with_apple_platform_interface]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- string_scanner 1.2.0 [source_span]
- term_glyph 1.2.1
- test_api 0.7.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- universal_platform 1.1.0
- url_launcher_android 6.3.9 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.2 [flutter url_launcher_platform_interface]
- vector_graphics 1.1.11+1 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path]
- vector_math 2.1.4
- vm_service 14.2.1
- web 1.0.0
- win32 5.5.4 [ffi]
- win32_registry 1.1.5 [ffi win32]
- xdg_directories 1.0.4 [meta path]
- xml 6.5.0 [collection meta petitparser]

Additional context and comments

No response

@gurgenAya gurgenAya added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 7, 2024
@SelaseKay SelaseKay added plugin: auth platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. labels Oct 7, 2024
@SelaseKay
Copy link
Contributor

Hi @gurgenAya , thanks for the report. I'm unable to reproduce this issue. What version of firebase_auth are you experiencing this on?

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 7, 2024
@gurgenAya
Copy link
Author

@SelaseKay Thanks for looking. The version of firebase auth is ^4.16.0.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 7, 2024
@SelaseKay
Copy link
Contributor

Kindly upgrade to the latest version (5.3.1) and try again.

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 7, 2024
@gurgenAya
Copy link
Author

@SelaseKay Updated to the latest versions of all packages from Firebase, but the issue remains.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 7, 2024
@SelaseKay
Copy link
Contributor

Have you tried testing with other email addresses?

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 7, 2024
@gurgenAya
Copy link
Author

@SelaseKay, I have tried using several different email addresses. The issue also persists when you use Apple Signin and Apple Provider with signInWithCredential.

Please note, as mentioned in the original report this only happens when When changing the Firebase Auth setting User account linking to Create multiple accounts for each identity provider from Firebase Console Auth Settings.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 7, 2024
@SelaseKay
Copy link
Contributor

Hi @gurgenAya , I followed your steps but can't seem to reproduce this issue. The email is always returned in my case. I tested on both Android and iOS.

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 7, 2024
@gurgenAya
Copy link
Author

@SelaseKay I can provide a minimal reproducible version, but the fact that the project must be linked to a firebase project with Google/Apple Auth integrations makes it impossible to share it publically.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 8, 2024
@SelaseKay
Copy link
Contributor

Can you create new project on your end and try it with that to see if the issue still persists?

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. plugin: auth type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants