firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.64k stars 1.48k forks source link

Firebase Auth Convert an anonymous account to a permanent account Error #11886

Closed davidarice closed 1 year ago

davidarice commented 1 year ago

Description

I'm trying to convert an anonymous user to a permanent user.

// link anonymous user to new credential let credential = EmailAuthProvider.credential(withEmail: email, password: password) try await auth.currentUser?.link(with: credential)

I would expect to see that the user has been converted to a permanent user, but I get an error: Error Domain=FIRAuthErrorDomain Code=17006 "Please verify the new email before changing email." UserInfo={NSLocalizedDescription=Please verify the new email before changing email., FIRAuthErrorUserInfoNameKey=ERROR_OPERATION_NOT_ALLOWED}

Reproducing the issue

// link anonymous user to new credential let credential = EmailAuthProvider.credential(withEmail: email, password: password) try await auth.currentUser?.link(with: credential)

I've used both the async/await functionality as well as the callback. I've also tried updating the user's email using updateEmail(to: <String>) with the same error, though I shouldn't need to do this.

Firebase SDK Version

10.15.0

Xcode Version

15.0

Installation Method

Swift Package Manager

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
```json { "pins" : [ { "identity" : "abseil-cpp-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/abseil-cpp-binary.git", "state" : { "revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c", "version" : "1.2022062300.0" } }, { "identity" : "firebase-ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/firebase-ios-sdk", "state" : { "revision" : "8a8ec57a272e0d31480fb0893dda0cf4f769b57e", "version" : "10.15.0" } }, { "identity" : "googleappmeasurement", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleAppMeasurement.git", "state" : { "revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b", "version" : "10.13.0" } }, { "identity" : "googledatatransport", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleDataTransport.git", "state" : { "revision" : "aae45a320fd0d11811820335b1eabc8753902a40", "version" : "9.2.5" } }, { "identity" : "googleutilities", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleUtilities.git", "state" : { "revision" : "c38ce365d77b04a9a300c31061c5227589e5597b", "version" : "7.11.5" } }, { "identity" : "grpc-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/grpc-binary.git", "state" : { "revision" : "f1b366129d1125be7db83247e003fc333104b569", "version" : "1.50.2" } }, { "identity" : "gtm-session-fetcher", "kind" : "remoteSourceControl", "location" : "https://github.com/google/gtm-session-fetcher.git", "state" : { "revision" : "5ccda3981422a84186387dbb763ba739178b529c", "version" : "2.3.0" } }, { "identity" : "interop-ios-for-google-sdks", "kind" : "remoteSourceControl", "location" : "https://github.com/google/interop-ios-for-google-sdks.git", "state" : { "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", "version" : "100.0.0" } }, { "identity" : "leveldb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/leveldb.git", "state" : { "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", "version" : "1.22.2" } }, { "identity" : "lottie-ios", "kind" : "remoteSourceControl", "location" : "https://github.com/airbnb/lottie-ios.git", "state" : { "revision" : "1760543c6e48e13fc76e9343f7006bcaee498a78", "version" : "4.3.1" } }, { "identity" : "nanopb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/nanopb.git", "state" : { "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", "version" : "2.30909.0" } }, { "identity" : "promises", "kind" : "remoteSourceControl", "location" : "https://github.com/google/promises.git", "state" : { "revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", "version" : "2.3.1" } }, { "identity" : "purchases-ios", "kind" : "remoteSourceControl", "location" : "https://github.com/RevenueCat/purchases-ios.git", "state" : { "revision" : "02a7da2dae8ca74c97ae0130b87a2787a4f36edf", "version" : "4.26.1" } }, { "identity" : "swift-protobuf", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { "revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d", "version" : "1.23.0" } }, { "identity" : "swiftuipager", "kind" : "remoteSourceControl", "location" : "https://github.com/fermoya/SwiftUIPager.git", "state" : { "revision" : "4ddc04c801aac143090bb14cf26603a3bf9c74cb", "version" : "2.5.0" } } ], "version" : 2 } ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

rizafran commented 1 year ago

Thanks for reporting, @davidarice. Per checking, it seems that the error is caused by the sign-in provider not being enabled in the Firebase project. With this, could you confirm if the Anonymous and Email/Password provider is enabled in your console?

davidarice commented 1 year ago

I can confirm that both Anonymous and Email/Password provider are enabled.

Screenshot 2023-10-03 at 9 05 21 AM
paulb777 commented 1 year ago

This issue is confirmed on recently created projects. The backend issue is internally tracked at b/302725971

paulb777 commented 1 year ago

See https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection for context and a possible workaround

davidarice commented 1 year ago

Thanks, Paul. I’ll disable email enumeration and see if that helps.

EDIT: I've confirmed that after disabling email enumeration in google cloud console I'm now able to convert from anonymous to a permanent account using email provider.