bug: MISSING_OR_INVALID_NONCE : Duplicate credential received. Please try again with a new credential.
See original GitHub issuePlugin(s):
- “@capacitor-firebase/authentication”: “0.3.1”,
- “@capacitor-firebase/messaging”: “0.3.1”,
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:
- Click “Sign in with Apple”
- Authorize the sign in request
- 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:
- Created a year ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is supported in the latest dev version, see https://github.com/capawesome-team/capacitor-firebase/pull/194#issuecomment-1229526459.
Yes, please see https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/authentication/docs/firebase-js-sdk.md#quirks
In this case I will close this issue.