I am trying Google login using React-native-google-signin plugin but it gives me a Developer_Error.I have done exctly same as mention in its document.here is my code ans steps.<
For React native projects:
There are many items in the checklist to get rid of DEVELOPER_ERROR. There seems to be lot of confusion around where the SHA-1 key needs to be set.
Once you have created android client_id in Google developer console you have an option to set SHA-1 key and package name.
You can get the package name from AndroidManifest.xml (projPath/android/app/src/main/AndroidManifest.xml) and set it in the text box in google developer console(very important to check for typos).
Then fetch your SHA-1 key from debug.keystore using following command for which password is "android"
First figure out location of keystore:
Your app may be either picking from
`pathToReactNativeProj/projName/android/app/debug.keystore`
or: ~/.android/debug.keystore
Then fetch your SHA-1 key from debug.keystore using following command for which password is android
keytool -exportcert -alias androiddebugkey -keystore pathToKeyStore -list -v
copy paste the SHA-1 key generated . This should solve the issue.
Code looks like following:
try {
GoogleSignin.configure(
{
//webClientId is required if you need offline access
offlineAccess: true,
webClientId:'2423432-43234234232432423234.apps.googleusercontent.com',
androidClientId: '3242343242322432-2342323432232324343323.apps.googleusercontent.com',
scopes: ['profile', 'email']
});
await GoogleSignin.hasPlayServices();
console.log("reached google sign in");
const userInfo = await GoogleSignin.signIn();
console.log(userInfo);
this.setState({ userInfo });
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log("error occured SIGN_IN_CANCELLED");
// user cancelled the login flow
} else if (error.code === statusCodes.IN_PROGRESS) {
console.log("error occured IN_PROGRESS");
// operation (f.e. sign in) is in progress already
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log("error occured PLAY_SERVICES_NOT_AVAILABLE");
} else {
console.log(error)
console.log("error occured unknow error");
}
}
Confusion around firebase SHA-1 key:
Setting this key is not required for fetching user info from google. Unless you are using firebase to store your users data you fetched from google you need not worry about it.