react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.12k stars 877 forks source link

[Error: A non-recoverable sign in failure occurred] #1223

Closed Ankush-Hegde closed 7 months ago

Ankush-Hegde commented 7 months ago

I am trying to implement the google oAuth login in my react-native android app.

I have gone through this article

THIS IS MY CODE

import {View, Text} from 'react-native';
import React, {useEffect} from 'react';
import {
  GoogleSignin,
  GoogleSigninButton,
  statusCodes,
} from '@react-native-google-signin/google-signin';

const App = () => {
  useEffect(() => {
    GoogleSignin.configure({
      webClientId:
        'xxxxxxxxxxxx-xxxxxxxxxxxxx45xxxxxxx0xxx4xxx.apps.googleusercontent.com',
      offlineAccess: true,
      forceCodeForRefreshToken: true,
    });
  });

  const signIn = async () => {
    try {
      await GoogleSignin.hasPlayServices();
      const userInfo = await GoogleSignin.signIn();

      console.log(userInfo);
    } catch (error: any) {
      if (error.code === statusCodes.SIGN_IN_CANCELLED) {
        console.log('User cancelled the login flow');
      } else if (error.code === statusCodes.IN_PROGRESS) {
        console.log('Signing in');
      } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
        console.log('Play services not available');
      } else {
        console.log('Some other error happened');
        console.log(error.message);
        console.log(error.code);
        console.log(error);
      }
    }
  };

  return (
    <View>
      <Text>App</Text>
      <GoogleSigninButton
        size={GoogleSigninButton.Size.Wide}
        color={GoogleSigninButton.Color.Dark}
        onPress={signIn}
      />
    </View>
  );
};

export default App;

when i searched for this error. I came to know that we need to use firebase to solve this. then i came across this article

where i got to know about this from that article

Walkthrough for different modes:

Development Firebase

Development non-Firebase

Production/Release version

i have tryed to implement using this method Development non-Firebase but still facing the same error

this is my error logs after selecting the google account to login

Some other error happened LOG A non-recoverable sign in failure occurred LOG 12500 LOG [Error: A non-recoverable sign in failure occurred]

and i get this when i run ./gradlew signingReport command

Task :app:signingReport Variant: debug Config: debug Store: C:\Users\username\Desktop\oAuth-google-react-native\AwesomeProject\android\app\debug.keystore Alias: androiddebugkey MD5: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA1: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA-256: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx Valid until: Wednesday, May 1, 2052

Variant: release Config: debug Store: C:\Users\username\Desktop\oAuth-google-react-native\AwesomeProject\android\app\debug.keystore Alias: androiddebugkey MD5: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA1: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA-256: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx Valid until: Wednesday, May 1, 2052

Variant: debugAndroidTest Config: debug Store: C:\Users\username\Desktop\oAuth-google-react-native\AwesomeProject\android\app\debug.keystore Alias: androiddebugkey MD5: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA1: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx SHA-256: xxx::xx::xxxx::xxxxx::xxxxxxxxxxxxx::xxxxxxx::xxxxxxx Valid until: Wednesday, May 1, 2052

Task :react-native-google-signin_google-signin:signingReport Variant: debugAndroidTest Config: debug Store: C:\Users\username.android\debug.keystore Alias: AndroidDebugKey Error: Missing keystore

BUILD SUCCESSFUL in 8s 7 actionable tasks: 2 executed, 5 up-to-date

Ankush-Hegde commented 7 months ago

fixed the problem.. i had different package name in google cloud and the project.. if we change the package name manually its not possible... i created the new project and copied the package name to google cloud

Ankush-Hegde commented 7 months ago

refer this https://medium.com/@mnabilarta/google-oauth-using-react-native-cli-23ce8e1cf716#:~:text=First%20you%20need%20to%20open,which%20is%20whatever%20you%20want