The audience in ID Token [com.name.apop] does not match the expected audience.

I am trying to implement sign in with apple with firebase. I cannot get around an issue where I get the following error when attempting a sign in:

When running:
Code Block
Auth.auth().signIn(with: credential) { (authResult, error) in


I get:

Code Block
nil credential = OAuthProvider.credential Optional(Error Domain=FIRAuthErrorDomain Code=17004 "The audience in ID Token [com.name.app] does not match the expected audience." UserInfo={NSLocalizedDescription=The audience in ID Token [com.name.app] does not match the expected audience., FIRAuthErrorUserInfoNameKey=ERROR_INVALID_CREDENTIAL})
Optional("The audience in ID Token [com.name.app] does not match the expected audience.")


I have added my URL as stated on firebase to my identifier.


To complete set up, add this authorization callback URL to your app configuration in the Apple Developer Console. Additional steps may be needed to verify ownership of this web domain to Apple. 


More code:

Code Block   
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
  if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
   guard let nonce = currentNonce else {
    fatalError("Invalid state: A login callback was received, but no login request was sent.")
   }
   guard let appleIDToken = appleIDCredential.identityToken else {
    print("Unable to fetch identity token")
    return
   }
   guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
    print("Unable to serialize token string from data: \(appleIDToken.debugDescription)")
    return
   }
     
    print("credential = OAuthProvider.credential")
   // Initialize a Firebase credential.
   let credential = OAuthProvider.credential(withProviderID: "apple.com",
                        idToken: idTokenString,
                      rawNonce: nonce)
    //Auth.auth().createUser(withEmail: T##String, password: T##String, completion: T##AuthDataResultCallback?##AuthDataResultCallback?##(AuthDataResult?, Error?) -> Void)
   // Sign in with Firebase.
   Auth.auth().signIn(with: credential) { (authResult, error) in
     
    print(Auth.auth().currentUser?.uid ," credential = OAuthProvider.credential ", error)



Accepted Reply

Solved:

I needed to change my bundle ID in my Xcode to the same one as firebase.

Replies

Solved:

I needed to change my bundle ID in my Xcode to the same one as firebase.

just change your bundle id of the project, make it the same as firebase. or vise versa, does not matter.