I am using Expo 37 with expo-google-app-auth 8.1.0. I am able to sign in users successfully. But in iOS, when a user clicks "cancel", whether in the Alert or the browser window, I get an error:
ERR_APP_AUTH: The operation couldn’t be completed. (org.openid.appauth.general error -3.)
This happens for both the simulator and standalone apps - again only for iOS. Why isn't it just returning an object with "type" : "cancel"?
Implementation of Google login method below:
signInWithGoogle = async (): Promise<void> => {
try {
const result = await Google.logInAsync({
androidClientId: ANDROID_CLIENT_ID,
iosClientId: IOS_CLIENT_ID,
androidStandaloneAppClientId: ANDROID_STANDALONE_CLIENT_ID,
iosStandaloneAppClientId: IOS_STANDALONE_CLIENT_ID,
scopes: ['profile', 'email'],
});
if (result.type === 'success') {
await firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
const credential = firebase.auth.GoogleAuthProvider.credential(result.idToken, result.accessToken);
const googleProfileData = await firebase.auth().signInWithCredential(credential);
if (googleProfileData.user.uid) {
this.props.setShouldBeLoggedOut(false);
this.props.setShouldPerformLogout(false);
} else {
Alert.alert('Unable to sync Google credentials with Authentication server');
}
}
} catch (error) {
Alert.alert('Google Login Error:', error.message);
}
};