FirebaseAuth: "The audience in ID Token does not match the expected audience" when I tried sign-in with Apple ID on Android Device

huangapple go评论67阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年4月19日 15:23:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76051747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定