I'm getting the following error while trying to add a sign up with apple in my nodejs backend:
status: auth/missing-or-invalid-nonce message: Duplicate credential received. Please try again with a new credential
Here is the code:
const clientId = 'com.mybusiness';
const { nonce: nonce } = await appleSignin.verifyIdToken(
appleIdentityToken,
{
audience: clientId,
ignoreExpiration: true,
}
);
const hashedNonce: string = crypto
.createHash('sha256')
.update(nonce)
.digest()
.toString();
const provider = new firebase.auth.OAuthProvider('apple.com');
const credential: OAuthCredential = provider.credential({
idToken: appleIdentityToken,
rawNonce: hashedNonce,
});
const userCredential: UserCredential = await this.clientAuth.signInWithCredential(
credential
);