I’m trying to implement google login in my react native application using @react-native-google-signin/google-signin
package. I followed all the steps in official documentation:(https://react-native-google-signin.github.io/docs/original). Still facing the error.
I’m using Django as the backend and want to implement google login without using Firebase.
Below is my code for the google login implementation:
I was follwing this guide: https://peerlist.io/blog/engineering/implementing-google-signin-in-react-native
The expected outcome was to have my userInfo saved in my user
state variable. But I’m entering the error catch block in GoogleLogin() with error statement:error fetching user info [Error: DEVELOPER_ERROR]
.
GoogleSignin.configure({
webClientId:
'xxxxxxxxxxxx.apps.googleusercontent.com',
androidClientId:
'xxxxxxxxxx.apps.googleusercontent.com',
iosClientId:
'xxxxxxxxxx.apps.googleusercontent.com',
scopes: ['profile', 'email'],
});
const GoogleLogin = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
return userInfo;
} catch (error) {
console.log('error fetching user info', error);
}
};
const handleGoogleLogin = async () => {
setGLoginLoading(true);
try {
const response = await GoogleLogin();
const {idToken, user} = response;
setUser(user);
if (idToken) {
const resp = await authAPI.validateToken({
token: idToken,
email: user.email,
});
await handlePostLoginData(resp.data);
}
} catch (apiError) {
setGLoginError(
apiError?.response?.data?.error?.message || 'Something went wrong',
);
} finally {
setGLoginLoading(false);
}
};
Can Anyone help with this please?