Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
iOS
Description
firebase_auth: 4.20.0
When converting an anonymous user to a registered account, linkWithProvider may throw an error if the account is already linked to another user. However, we can recover from the error by signing in to the account using the credential from FirebaseAuthException and calling the signInWithCredential function. But for some reason, it throws an error: "[firebase_auth/invalid-credential] The supplied auth credential is malformed, has expired, or is not currently supported." It also prints, "Support for an auth provider with identifier 'apple.com' is not implemented," even though Apple Auth is enabled. The process works fine when used with signInWithProvider. So it seems there is something wrong with the credential passed by the error.
Reproducing the issue
/// Prerequisites:
///
/// 1. Make sure that your Apple account is already linked to another user.
/// 2. Make sure you are unauthenticated.
///
/// Issues:
///
/// 1. The token is negative in AuthCredential: `-7025765327691696085`.
/// 2. [invalid-credential] is thrown when trying to signInWithCredential.
/// 3. The following text is printed: "Support for an auth provider with
/// identifier 'apple.com' is not implemented." Even though Apple auth
/// works fine when used with a credential outside of the error.
///
/// How it should work:
///
/// 1. `signInWithCredential` should authenticate successfully.
Future<void> signInAsGuestAndConvertToRegisteredUser() async {
await FirebaseAuth.instance.signInAnonymously();
final provider = AppleAuthProvider();
final user = FirebaseAuth.instance.currentUser;
if (user != null && user.isAnonymous) {
try {
await user.linkWithProvider(provider);
} on FirebaseAuthException catch (error) {
final credential = error.credential;
print(credential);
if (credential != null) {
await FirebaseAuth.instance.signInWithCredential(credential);
}
} catch (_) {}
}
}
Firebase Core version
2.32.0
Flutter Version
3.22.0
Relevant Log Output
No response
Flutter dependencies
Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
Maybe related to #12931 and #11841.
The issue is reproducible on the latest versions:
firebase_core: 3.1.0
firebase_auth: 5.1.0
The issue is reproducible on the following versions:
firebase_core: 2.32.0
firebase_auth: 4.20.0
The issue is NOT reproducible on the following versions:
firebase_core: 2.31.0
firebase_auth: 4.19.5
There is interesting error when using the following versions:
firebase_core: 2.32.0
firebase_auth: 4.19.5
Click to see the error
[log] type 'List<Object?>' is not a subtype of type 'PigeonUserDetails?' in type cast
#0 PigeonUserCredential.decode (package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart:432:23)
#1 _FirebaseAuthHostApiCodec.readValueOfType (package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart:830:37)
#2 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#3 StandardMessageCodec.readValueOfType (package:flutter/src/services/message_codecs.dart:522:23)
#4 _FirebaseAuthHostApiCodec.readValueOfType (package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart:840:22)
#5 StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:477:12)
#6 StandardMessageCodec.decodeMessage (package:flutter/src/services/message_codecs.dart:341:28)
#7 BasicMessageChannel.send (package:flutter/src/services/platform_channel.dart:218:18)
<asynchronous suspension>
#8 FirebaseAuthHostApi.signInWithCredential (package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart:1094:9)
<asynchronous suspension>
#9 MethodChannelFirebaseAuth.signInWithCredential (package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart:306:22)
<asynchronous suspension>
#10 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:543:9)
<asynchronous suspension>
Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
iOS
Description
firebase_auth: 4.20.0
When converting an anonymous user to a registered account,
linkWithProvidermay throw an error if the account is already linked to another user. However, we can recover from the error by signing in to the account using the credential fromFirebaseAuthExceptionand calling thesignInWithCredentialfunction. But for some reason, it throws an error: "[firebase_auth/invalid-credential] The supplied auth credential is malformed, has expired, or is not currently supported." It also prints, "Support for an auth provider with identifier 'apple.com' is not implemented," even though Apple Auth is enabled. The process works fine when used withsignInWithProvider. So it seems there is something wrong with the credential passed by the error.Reproducing the issue
Firebase Core version
2.32.0
Flutter Version
3.22.0
Relevant Log Output
No response
Flutter dependencies
Expand
Flutter dependenciessnippetReplace this line with the contents of your `flutter pub deps -- --style=compact`.Additional context and comments
Maybe related to #12931 and #11841.
The issue is reproducible on the latest versions:
firebase_core: 3.1.0
firebase_auth: 5.1.0
The issue is reproducible on the following versions:
firebase_core: 2.32.0
firebase_auth: 4.20.0
The issue is NOT reproducible on the following versions:
firebase_core: 2.31.0
firebase_auth: 4.19.5
There is interesting error when using the following versions:
firebase_core: 2.32.0
firebase_auth: 4.19.5
Click to see the error