英文:
FirebaseAuth: "The audience in ID Token does not match the expected audience" when I tried sign-in with Apple ID on Android Device
问题
I'm facing this issue after I entered any Apple ID account and press "Continue" using an Android device:
> FirebaseAuthException ([firebase_auth/invalid-credential] The supplied auth credential is malformed or has expired. [The audience in ID Token [My ServiceID] does not match the expected audience.])
If I use an iPhone, it works successfully, the problem is after I entered any Apple ID account in the AppleId web view using any Android device.
here is my code:
static Future<UserCredential> signInWithApple() async {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: FIREBASE_BUNDLE_ID //I have this data according to package documentation
redirectUri: Uri.parse(
'https://MI_PROJECT_ID.cloudfunctions.net/handleAppleSignIn')),
);
final oauthCredential = OAuthProvider('apple.com').credential(
idToken: appleCredential.identityToken,
accessToken: appleCredential.authorizationCode,
);
final UserCredential appleUser =
await FirebaseAuth.instance.signInWithCredential(oauthCredential);
return appleUser;
}
Im using sign_in_with_apple: ^4.3.0
, firebase_core: ^2.3.0
and firebase_auth: ^4.4.0
I have my project registered in firebase and developer.apple.com, the Apple provider as Sign-In provider
also OAuth 2.0 Client IDs
registration and all the setup of the https://pub.dev/packages/sign_in_with_apple package, the intent://callback?${PARAMETERS FROM CALLBACK BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end
I also configured the Apple ServiceId with the return URL for using Firebase Cloud Functions
If I use the Apple Id sign in option on any Android device, is it considered a Web method and do I need to use FirebaseAuth.instance.signInWithPopup()
as the page https://firebase.google.com/docs/auth/flutter/federated-auth?hl=en&authuser=0#android_1 says?
英文:
I'm facing this issue after I entered any Apple ID account and press "Continue" using an Android device:
> FirebaseAuthException ([firebase_auth/invalid-credential] The supplied auth credential is malformed or has expired. [The audience in ID Token [My ServiceID] does not match the expected audience. ])
If I use an iPhone, it works successfully, the problem is after I entered any Apple ID account in the AppleId web view using any Android device.
here is my code:
static Future<UserCredential> signInWithApple() async {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: FIREBASE_BUNDLE_ID //I have this data according to package documentation
redirectUri: Uri.parse(
'https://MI_PROJECT_ID.cloudfunctions.net/handleAppleSignIn')),
);
final oauthCredential = OAuthProvider('apple.com').credential(
idToken: appleCredential.identityToken,
accessToken: appleCredential.authorizationCode,
);
final UserCredential appleUser =
await FirebaseAuth.instance.signInWithCredential(oauthCredential);
return appleUser;
}
Im using sign_in_with_apple: ^4.3.0
, firebase_core: ^2.3.0
and firebase_auth: ^4.4.0
I have my project registered in firebase and developer.apple.com, the Apple provider as Sign-In provider
also OAuth 2.0 Client IDs
registration and all the setup of the https://pub.dev/packages/sign_in_with_apple package, the intent://callback?${PARAMETERS FROM CALLBACK BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end
I also configured the Apple ServiceId with the return URL for using Firebase Cloud Functions
If I use the Apple Id sign in option on any Android device, is it considered a Web method and do I need to use FirebaseAuth.instance.signInWithPopup()
as the page https://firebase.google.com/docs/auth/flutter/federated-auth?hl=en&authuser=0#android_1 says?
答案1
得分: 1
已解决:
在将Google Cloud凭据的Apple OAuth客户端ID放在dev apple页面中的Sign with Apple设置的正确Service ID之外时,我感到困惑。
英文:
Solved:
I got confused when putting the Apple OAuth client ID of the Google Cloud credentials instead of the correct Service ID of the Sign with Apple setup in dev apple page.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论