firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Error When Re-Linking Google Account to New Anonymous User After Unlinking

Open TarekkMA opened this issue 10 months ago • 2 comments

Description

The original issue report is documented in firebase/flutterfire#12538.

The behavior observed aligns with the patterns described in the aforementioned issue. Detailed steps to reproduce this behavior are provided for clarity.

Reproducing the issue

  1. Sign in with an anonymous user
    • On the Firebase console, it will be added with the identifier (anonymous).
  2. Link the account with a Google account ([email protected]).
    • On the Firebase console, it's linked, and the identifier is your Google mail ([email protected]).
  3. Unlink the Google account.
  4. Create a new anonymous user, try to link it with ([email protected]).
    • You will get an error: The email address is already in use by another account.

Firebase SDK Version

10.22.0

Xcode Version

15.3

Installation Method

CocoaPods

Firebase Product(s)

Authentication

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

PODS:
  - AppAuth (1.7.3):
    - AppAuth/Core (= 1.7.3)
    - AppAuth/ExternalUserAgent (= 1.7.3)
  - AppAuth/Core (1.7.3)
  - AppAuth/ExternalUserAgent (1.7.3):
    - AppAuth/Core
  - FBAEMKit (16.3.1):
    - FBSDKCoreKit_Basics (= 16.3.1)
  - FBSDKCoreKit (16.3.1):
    - FBAEMKit (= 16.3.1)
    - FBSDKCoreKit_Basics (= 16.3.1)
  - FBSDKCoreKit_Basics (16.3.1)
  - FBSDKLoginKit (16.3.1):
    - FBSDKCoreKit (= 16.3.1)
  - Firebase/Auth (10.22.0):
    - Firebase/CoreOnly
    - FirebaseAuth (~> 10.22.0)
  - Firebase/CoreOnly (10.22.0):
    - FirebaseCore (= 10.22.0)
  - Firebase/Messaging (10.22.0):
    - Firebase/CoreOnly
    - FirebaseMessaging (~> 10.22.0)
  - firebase_auth (4.19.0):
    - Firebase/Auth (= 10.22.0)
    - firebase_core
    - Flutter
  - firebase_core (2.28.0):
    - Firebase/CoreOnly (= 10.22.0)
    - Flutter
  - firebase_messaging (14.8.0):
    - Firebase/Messaging (= 10.22.0)
    - firebase_core
    - Flutter
  - FirebaseAppCheckInterop (10.23.0)
  - FirebaseAuth (10.22.0):
    - FirebaseAppCheckInterop (~> 10.17)
    - FirebaseCore (~> 10.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.8)
    - GoogleUtilities/Environment (~> 7.8)
    - GTMSessionFetcher/Core (< 4.0, >= 2.1)
    - RecaptchaInterop (~> 100.0)
  - FirebaseCore (10.22.0):
    - FirebaseCoreInternal (~> 10.0)
    - GoogleUtilities/Environment (~> 7.12)
    - GoogleUtilities/Logger (~> 7.12)
  - FirebaseCoreInternal (10.23.0):
    - "GoogleUtilities/NSData+zlib (~> 7.8)"
  - FirebaseInstallations (10.23.0):
    - FirebaseCore (~> 10.0)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/UserDefaults (~> 7.8)
    - PromisesObjC (~> 2.1)
  - FirebaseMessaging (10.22.0):
    - FirebaseCore (~> 10.0)
    - FirebaseInstallations (~> 10.0)
    - GoogleDataTransport (~> 9.3)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.8)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/Reachability (~> 7.8)
    - GoogleUtilities/UserDefaults (~> 7.8)
    - nanopb (< 2.30911.0, >= 2.30908.0)
  - Flutter (1.0.0)
  - flutter_facebook_auth (6.0.4):
    - FBSDKLoginKit (~> 16.3.1)
    - Flutter
  - flutter_secure_storage (6.0.0):
    - Flutter
  - google_sign_in_ios (0.0.1):
    - Flutter
    - FlutterMacOS
    - GoogleSignIn (~> 7.0)
  - GoogleDataTransport (9.4.1):
    - GoogleUtilities/Environment (~> 7.7)
    - nanopb (< 2.30911.0, >= 2.30908.0)
    - PromisesObjC (< 3.0, >= 1.2)
  - GoogleSignIn (7.1.0):
    - AppAuth (< 2.0, >= 1.7.3)
    - GTMAppAuth (< 5.0, >= 4.1.1)
    - GTMSessionFetcher/Core (~> 3.3)
  - GoogleUtilities/AppDelegateSwizzler (7.13.0):
    - GoogleUtilities/Environment
    - GoogleUtilities/Logger
    - GoogleUtilities/Network
    - GoogleUtilities/Privacy
  - GoogleUtilities/Environment (7.13.0):
    - GoogleUtilities/Privacy
    - PromisesObjC (< 3.0, >= 1.2)
  - GoogleUtilities/Logger (7.13.0):
    - GoogleUtilities/Environment
    - GoogleUtilities/Privacy
  - GoogleUtilities/Network (7.13.0):
    - GoogleUtilities/Logger
    - "GoogleUtilities/NSData+zlib"
    - GoogleUtilities/Privacy
    - GoogleUtilities/Reachability
  - "GoogleUtilities/NSData+zlib (7.13.0)":
    - GoogleUtilities/Privacy
  - GoogleUtilities/Privacy (7.13.0)
  - GoogleUtilities/Reachability (7.13.0):
    - GoogleUtilities/Logger
    - GoogleUtilities/Privacy
  - GoogleUtilities/UserDefaults (7.13.0):
    - GoogleUtilities/Logger
    - GoogleUtilities/Privacy
  - GTMAppAuth (4.1.1):
    - AppAuth/Core (~> 1.7)
    - GTMSessionFetcher/Core (< 4.0, >= 3.3)
  - GTMSessionFetcher/Core (3.3.2)
  - nanopb (2.30910.0):
    - nanopb/decode (= 2.30910.0)
    - nanopb/encode (= 2.30910.0)
  - nanopb/decode (2.30910.0)
  - nanopb/encode (2.30910.0)
  - path_provider_foundation (0.0.1):
    - Flutter
    - FlutterMacOS
  - PromisesObjC (2.4.0)
  - RecaptchaInterop (100.0.0)
  - shared_preferences_foundation (0.0.1):
    - Flutter
    - FlutterMacOS
  - url_launcher_ios (0.0.1):
    - Flutter

DEPENDENCIES:
  - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
  - firebase_core (from `.symlinks/plugins/firebase_core/ios`)
  - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
  - Flutter (from `Flutter`)
  - flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`)
  - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
  - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
  - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
  - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
  - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
  trunk:
    - AppAuth
    - FBAEMKit
    - FBSDKCoreKit
    - FBSDKCoreKit_Basics
    - FBSDKLoginKit
    - Firebase
    - FirebaseAppCheckInterop
    - FirebaseAuth
    - FirebaseCore
    - FirebaseCoreInternal
    - FirebaseInstallations
    - FirebaseMessaging
    - GoogleDataTransport
    - GoogleSignIn
    - GoogleUtilities
    - GTMAppAuth
    - GTMSessionFetcher
    - nanopb
    - PromisesObjC
    - RecaptchaInterop

EXTERNAL SOURCES:
  firebase_auth:
    :path: ".symlinks/plugins/firebase_auth/ios"
  firebase_core:
    :path: ".symlinks/plugins/firebase_core/ios"
  firebase_messaging:
    :path: ".symlinks/plugins/firebase_messaging/ios"
  Flutter:
    :path: Flutter
  flutter_facebook_auth:
    :path: ".symlinks/plugins/flutter_facebook_auth/ios"
  flutter_secure_storage:
    :path: ".symlinks/plugins/flutter_secure_storage/ios"
  google_sign_in_ios:
    :path: ".symlinks/plugins/google_sign_in_ios/darwin"
  path_provider_foundation:
    :path: ".symlinks/plugins/path_provider_foundation/darwin"
  shared_preferences_foundation:
    :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
  url_launcher_ios:
    :path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
  AppAuth: a13994980c1ec792f7e2e665acd4d4aa6be43240
  FBAEMKit: 6c7b5eb77c96861bb59e040842c6e55bf39512ce
  FBSDKCoreKit: 5e4dd478947ab1bcc887e8cfadeae0727af1a942
  FBSDKCoreKit_Basics: cd7b5f5d1e8868c26706917919d058999ca672c3
  FBSDKLoginKit: 572cca0bc6c90067ef197187697cb3b584310c52
  Firebase: 797fd7297b7e1be954432743a0b3f90038e45a71
  firebase_auth: bd4ebe97d1e836aa5692b75c8f13412ed4381871
  firebase_core: d955499180c3c8ef355adf46b8752c4c01d09e0a
  firebase_messaging: 23c8eaa885a11552e45c98b7a08ba81860092883
  FirebaseAppCheckInterop: a1955ce8c30f38f87e7d091630e871e91154d65d
  FirebaseAuth: bbe4c68f958504ba9e54aee181adbdf5b664fbc6
  FirebaseCore: 0326ec9b05fbed8f8716cddbf0e36894a13837f7
  FirebaseCoreInternal: 6a292e6f0bece1243a737e81556e56e5e19282e3
  FirebaseInstallations: 42d6ead4605d6eafb3b6683674e80e18eb6f2c35
  FirebaseMessaging: 9f71037fd9db3376a4caa54e5a3949d1027b4b6e
  Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
  flutter_facebook_auth: c8700ab1770f3d8e5e7456220e4f3bbcdb831454
  flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
  google_sign_in_ios: 989eea5abe94af62050782714daf920be883d4a2
  GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
  GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db
  GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152
  GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de
  GTMSessionFetcher: 0e876eea9782ec6462e91ab872711c357322c94f
  nanopb: 438bc412db1928dac798aa6fd75726007be04262
  path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
  PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
  RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21
  shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
  url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586

PODFILE CHECKSUM: 329a5fe659b48e1f9eb6aa93d909bbbadd8d6bbb

COCOAPODS: 1.15.2

TarekkMA avatar Apr 02 '24 13:04 TarekkMA

Thanks for filing this, @TarekkMA. I was able to reproduce the same behavior, but it seems working as intended. The reason why you're getting the error The email address is already in use by another account. might be because the Google account you tried to link anonymously is already existing. When you sign in again with that Google account after unlinking, if it's already existing with the same email, the Google credential will automatically merge with that account. You may check this related ticket for more info.

rizafran avatar Apr 03 '24 19:04 rizafran

@rizafran Sorry, but what is the use case for this?

The original reason for reporting this issue is for the very common use case of a user trying to change their email on to a different firebase auth account.

After reading the above mentioned issue it says that it's not possible to simply delete the primary email address. But users want to do this. In fact, though I have not checked any actual policies, I'm not sure if this is legal?

The user has specifically said "Remove my email from this account" yet it's still saved in firebase's authentication system. You aren't allowed to do that right?

Moncader avatar Apr 04 '24 02:04 Moncader

@rizafran Any update on this? It was reopened 2 weeks ago but then no visible movement from our side.

Moncader avatar Apr 17 '24 01:04 Moncader

Hi, thank you for filing this issue and sharing your suggestion. As mentioned above, this is an expected behavior and we don't have plans to support this use case at the moment.

NhienLam avatar Apr 22 '24 21:04 NhienLam

@NhienLam @paulb777 I don't think you're understanding the core issue with this.

If this is currently the expected behaviour, that means with Firebase Authentication and Google Login, it's impossible for us developers to let a user know how they can use their own Google account on a different Firebase account. The current SDK's don't allow us to know that once you unlink a Google account, magically in the backend of Firebase you've attached that email even though the email link is not active according to the SDK.

If it's the expected behaviour, please let us know how we can simply show a user, "Hey, it looks like you used Google in the past as your account link, you need to either delete you account 100% and try again (not realistic), or manually link your email with the email link system, and then unlink the email system again."

I don't see a way to detect this from the SDK.

Moncader avatar Apr 23 '24 01:04 Moncader

Is deleting [email protected] as a step 3.5 a workaround?

paulb777 avatar Apr 23 '24 22:04 paulb777

Do you mean deleting the firebase auth account? If so the answer is that yes, you can use the gmail address again, but no that is not a workaround. That's asking the user to delete our service account just to unlink a social account from the user's service account.

Moncader avatar Apr 24 '24 05:04 Moncader

It seems that the console keeps the first gmail account as the identifier for the user created by the original anonymous user, even though it's google provider is deleted.

paulb777 avatar Apr 25 '24 22:04 paulb777

@paulb777 So what's the next move here? Is the console supposed to be doing that? If the console is messed up, I would lean to believing that the SDK's get odd data (like we see) as well. And of course my original question from above still stands.

Moncader avatar May 08 '24 08:05 Moncader

@Moncader Yes, this seems to be how the service is defined to behave.

paulb777 avatar May 09 '24 00:05 paulb777

@paulb777 Ok, then what can us developers do for our users in regards to https://github.com/firebase/firebase-ios-sdk/issues/12678#issuecomment-2071247361 ?

I can't see a way detect when a user attempts to change gmail accounts to a different firebase account and let the user know they have to:

  1. delete the account
  2. do a regular email link and then delete that

Both of which imo are major hacks and make absolutely no sense in terms of an SDK specification...

Can the firebase team please let us know how to support our users here?

Moncader avatar May 09 '24 00:05 Moncader