question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: MISSING_OR_INVALID_NONCE : Duplicate credential received. Please try again with a new credential.

See original GitHub issue

Plugin(s):

Platform(s):

iOS

Current behavior:

When I attempt to login using “Sign in with Apple” on an iOS device, the authentication process fails with the following error returned from https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=xxx:

{
  "error": {
    "code": 400,
    "message": "MISSING_OR_INVALID_NONCE : Duplicate credential received. Please try again with a new credential.",
    "errors": [
      {
        "message": "MISSING_OR_INVALID_NONCE : Duplicate credential received. Please try again with a new credential.",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

Expected behavior:

Expect the login process to complete successfully, as it currently does on Android / web.

Steps to reproduce:

  1. Click “Sign in with Apple”
  2. Authorize the sign in request
  3. Wait for response

Related code:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
import { AuthCredential, AuthErrorCodes, browserLocalPersistence, EmailAuthProvider, getAuth, GoogleAuthProvider, OAuthCredential, OAuthProvider, sendEmailVerification, sendPasswordResetEmail, setPersistence, signInWithCredential, signOut, type AuthError } from 'firebase/auth'

const _signInWithCredential = async (credential: OAuthCredential | AuthCredential) => {
  await signInWithCredential(authInstance, credential)
  setPersistence(authInstance, browserLocalPersistence)
}

export default {
  signInWithApple: async (): Promise<void> => {
    const result = await FirebaseAuthentication.signInWithApple()
    const provider = new OAuthProvider('apple.com')
    const credential = provider.credential({
      idToken: result.credential?.idToken,
      rawNonce: result.credential?.nonce
    })
    await _signInWithCredential(credential)
  },
}

Other information:

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.2.0
  @capacitor/core: 4.2.0
  @capacitor/android: 4.2.0
  @capacitor/ios: 4.2.0

Installed Dependencies:

  @capacitor/cli: 3.7.0
  @capacitor/core: 3.7.0
  @capacitor/ios: 3.7.0
  @capacitor/android: 3.7.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
robingenzcommented, Sep 20, 2022
1reaction
robingenzcommented, Sep 20, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error linking Apple account on Firebase: Duplicate credential ...
[Error: [auth/unknown] Duplicate credential received. Please try again with a new credential.] Desired outcome: Apple account and phone number are linked as ...
Read more >
Reuse Credential for Sign in with Apple in Firebase iOS
I'm always requesting new one and using them in the fetchProvider method and I get new credentials via OAuth and there is no...
Read more >
The audience in ID Token [com.name… - Apple Developer
I am trying to implement sign in with apple with firebase. ... nil credential = OAuthProvider.credential Optional(Error Domain=FIRAuthErrorDomain Code=17004 ...
Read more >
Authenticate Using Apple | Firebase - Google
The new credential will be located in the error's userInfo dictionary and can be accessed via the FIRAuthErrorUserInfoUpdatedCredentialKey key. For example, to ...
Read more >
Apple Sign In with Flutter & Firebase Authentication
The three possible cases are authorized , error and cancelled . Authorized. If the request was authorized, we create an OAuthProvider credential with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found