I am using Firebase User Account Linking with Firebase Auth on Flutter. When an account with email address x already exists and the users signs up with google sign in and the same email address, everything works fine, and accounts are linked.
When using apple sign in and the signInWithProvider method from the firebase auth flutter docs, I get an internal server error with not details. When using the sign_in_with_apple package and an oauth provider, I get the error [error] type 'int' is not a subtype of type 'String' in type cast.
Heres the two code snippets:
UserCredential userCredential;
if (kIsWeb) {
userCredential =
await FirebaseAuth.instance.signInWithPopup(appleProvider);
} else {
userCredential =
await FirebaseAuth.instance.signInWithProvider(appleProvider);
}
Raises an internal server error.
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
],
);
final oauthCredential = OAuthProvider('apple.com').credential(
accessToken: credential.authorizationCode,
idToken: credential.identityToken,
);
final userCredential =
await firebaseAuth.signInWithCredential(oauthCredential);
Raises the error: type 'int' is not a subtype of type 'String' in type cast.
On Google Identity Platform docs, I found that in order to link apple accounts: Note that Apple requires you to get explicit consent from users before you link their Apple accounts to other data.
But I can't find any information on how to do that.
Thank you in advance for your help!