I am trying to implement React Native Firebase Auth using expo-apple-authentication. I have added Apple as a provider on the Firebase Auth Console but because the expo-apple-authentication returns an identity token and an authorisation code instead of an identity token and a nonce as per the documentation, I am not able to authenticate using React Native Firebase. I tried generating a nonce manually to go along with the identity token but got [auth/invalid-credential] The supplied auth credential is malformed or has expired.
Does anyone know how to do this?
My current code
const signInWApple = async () => {
try {
const credential = await AppleAuthentication.signInAsync({
requestedScopes: [
AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
AppleAuthentication.AppleAuthenticationScope.EMAIL,
],
});
// Ensure Apple returned a user identityToken
if (!credential.identityToken) {
throw new Error("Apple Sign-In failed - no identify token returned");
}
// Create a Firebase credential from the response
const { identityToken } = credential;
const nonce = generateRandomNonce();
const appleCredential = auth.AppleAuthProvider.credential(
identityToken,
nonce
);
// Sign the user in with the credential
await auth().signInWithCredential(appleCredential);
}