- SDK Version: 40.0
- Platforms(Android/iOS/web/all): iOS
- Add the appropriate “Tag” based on what Expo library you have a question on.
I’ve been following AppleAuthentication - Expo Documentation to implement Apple authentication with firebase.
This is the snippet of code I am using for the onPress
method:
const csrf = Math.random().toString(36).substring(2, 15);
const nonce = Math.random().toString(36).substring(2, 10);
const hashedNonce = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
nonce
);
const appleCredential = await AppleAuthentication.signInAsync({
requestedScopes: [
AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
AppleAuthentication.AppleAuthenticationScope.EMAIL,
],
state: csrf,
nonce: hashedNonce,
});
console.log("Apple credentials", appleCredential);
const { identityToken } = appleCredential;
if (identityToken) {
const provider = new firebase.auth.OAuthProvider("apple.com");
const credential = provider.credential({
idToken: identityToken,
rawNonce: nonce,
});
firebase
.auth()
.signInWithCredential(credential)
.then((res) => {
console.log("Successfully signed in with Apple ID", res);
})
.catch((err) => {
console.error(err);
});
}
When I try to login on the Expo Go app on my iOS device, it throws the following error:
The audience in ID Token [host.exp.Exponent] does not match the expected audience.
This seems to be a common issue: I tried following this recommendation of setting the Services ID
to host.expo.Exponent
to no avail.
I’ve also even tried adding a separate iOS app with bundler ID ‘host.expo.Exponent’ to my Firebase project (and using the associated GoogleServices-Info.plist
file) to no avail.