Google signin not working on IOS (17.04)
Closed this issue · 1 comments
RinNguyens commented
Google signin not working on IOS (17.04)
LOG RNGoogleSignInError: Unknown error in google sign in., Error Domain=org.openid.appauth.general Code=-15 "ID Token expired" UserInfo={NSLocalizedDescription=ID Token expired}
Code below :
import React from 'react';
import {
SafeAreaView,
Button,
View,
} from 'react-native';
import auth from '@react-native-firebase/auth';
import {
GoogleSignin,
statusCodes,
} from '@react-native-google-signin/google-signin';
import {LoginManager, AccessToken} from 'react-native-fbsdk-next';
import {sha256} from 'react-native-sha256';
import {GoogleSigninButton} from '@react-native-google-signin/google-signin';
GoogleSignin.configure({
webClientId:
'349571960167-bpreej8pan5o9011sbq99fo6m0skjo73.apps.googleusercontent.com',
iosClientId:
'349571960167-kc3g2v5q8mitap97roso6af9pn7mn1s0.apps.googleusercontent.com',
offlineAccess: true,
// iosClientId: '349571960167-kc3g2v5q8mitap97roso6af9pn7mn1s0.apps.googleusercontent.com'
});
function App() {
const signOut = async () => {
try {
await GoogleSignin.signOut();
setState({user: null}); // Remember to remove the user from your app's state as well
} catch (error) {
console.error(error);
}
};
async function onGoogleButtonPress() {
try {
await GoogleSignin.hasPlayServices({showPlayServicesUpdateDialog: true});
// Get the users ID token
const userInfo = await GoogleSignin.signIn();
console.log(userInfo, 'userInfo')
// Create a Google credential with the token
const googleCredential = auth.GoogleAuthProvider.credential(userInfo.idToken);
// Sign-in the user with the credential
return auth().signInWithCredential(googleCredential);
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log(statusCodes.SIGN_IN_CANCELLED)
// user cancelled the login flow
} else if (error.code === statusCodes.IN_PROGRESS) {
// operation (e.g. sign in) is in progress already
console.log(statusCodes.IN_PROGRESS)
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
// play services not available or outdated
console.log(statusCodes.PLAY_SERVICES_NOT_AVAILABLE)
} else {
// some other error happened
console.log(error.message);
}
}
}
return (
<SafeAreaView>
<View>
<GoogleSigninButton onPress={() => onGoogleButtonPress().then(() => console.log('success 123123'))} />
</View>
</SafeAreaView>
);
}
export default App;
Detail :
"dependencies": {
"@react-native-firebase/app": "^19.2.2",
"@react-native-firebase/auth": "^19.2.2",
"@react-native-google-signin/google-signin": "^11.0.1",
"react": "18.2.0",
"react-native": "0.74.1",
"react-native-fbsdk-next": "^13.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.74.83",
"@react-native/eslint-config": "0.74.83",
"@react-native/metro-config": "0.74.83",
"@react-native/typescript-config": "0.74.83",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
},
vonovak commented
Hello and thanks for reporting,
ID Token expired
I think that's the problem there ^
Thank you 🙂