Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google sign in error Status{statusCode=DEVELOPER_ERROR, resolution=null}

I am integrating gmail login in my android application by following this thread :

https://developers.google.com/identity/sign-in/android/sign-in?configured=true

But I am getting error as :

Status{statusCode=DEVELOPER_ERROR, resolution=null}

I looked through this status code documentation here :

https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult.html#DEVELOPER_ERROR

Above link does not help to diagnose the problem,

I have created the debug keystore file, & generated SHA-1 using keytool, also in Google developer console, I added package name as it is in manifest file or gradle file.

But all seems to fail can anybody tell me what does this error code suggest what may go wrong ?

like image 982
Prashant Avatar asked Oct 17 '16 14:10

Prashant


6 Answers

Problem was SHA1 mismatch,

1] First Keystore File : I solved the error, problem was while building apk Android studio was taking default keystore file which was located inside C:\Users\<LOGGED_IN_USER_NAME>\.android\debug.keystore

2] Second Keystore File : Also I created one other keystore file which was located at different directory i.e. app/keystore/debug.keystore

While configuring the google developer console to integrate gmail login within app I gave sha-1 key generated through second keystore file above, the studio while building the apk file taking other keystore file hence sha-1 key mismatch was happening.

In order to take my keystore file located @ app/keystore/debug.keystore I configured gradle file at app level with following code :

signingConfigs {
        debug {
            storeFile file('keystore/debug.keystore')
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storePassword 'android'
        }
        /*
        release {
            storeFile file('release.keystore')
            storePassword "mystorepassword"
            keyAlias "mykeyalias"
            keyPassword "mykeypassword"
        }
        */

Now the generated apk sha-1 signature matches with the sha-1 key configured on google developer console for your app.

One note : Always use debug.keystore for debugging the gmail integration (At the time of development).

Refs :

For gmail integration : https://developers.google.com/identity/sign-in/android/start-integrating

To see which sha-1 is getting used for your application see this stackoverflow thread : SHA-1 fingerprint of keystore certificate

like image 97
Prashant Avatar answered Oct 06 '22 01:10

Prashant


For anyone who is using React Native Google Signin and Firebase, try this.

Step 1: Get the SHA-1 of your Android Developer Debug Keystore

keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

The password is android. Copy the SHA-1 value, which will look something like this in the output:

Certificate Fingerprints
....
SHA1: aa:bb:cc:dd:ee:ff:11:22:33:44:47:D0:9E:8D:E0:0C:79:F1:0F:CB

Step 2: Add the SHA to the Android App in the Firebase Console

Now open up your Android App in the Firebase console and add the SHA-1:

enter image description here

like image 43
Dave Kerr Avatar answered Oct 06 '22 01:10

Dave Kerr


For react native app google login I followed following steps and it worked

  • Setup app in firebase console for iOS/Android on the following link https://console.firebase.google.com/
  • Download GoogleService-Info.plist for iOS and google-services.json for Android
  • Don't forget to set SHA certificate fingerprints SHA1 for android setup. It's mandatory to work with Android.
  • Then copy Web client (auto created by Google Service) from OAuth 2.0 client IDs from following URL to access Google developer console https://console.developers.google.com/
  • After doing all of these steps in firebase developer console and Google developer console
  • move to your code Open your .js file from where you provide an option to login via Google.
  • In componentDidMount place following code

GoogleSignin.configure({
      iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
      webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
      offlineAccess: false
    });

or you can create a separate method like this and call it in componentDidMount to configure GoogleSignIn

 async setupGoogleSignin() {
    try {
      await GoogleSignin.hasPlayServices//({ autoResolve: true });
      await GoogleSignin.configure({
        iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
        webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
        offlineAccess: true
      });

      const user = await GoogleSignin.currentUserAsync();
      console.log("user from google sin in", user);
    } catch (err) {
      console.log("Google signin error", err.code, err.message);
    }
  }

After configuring GoogleSignIn you can call the following method on the press of GoogleSignInButton

googleAuth() {
    GoogleSignin.signIn()
      .then(user => {
        console.log("user==", user);
        console.log("user name = ", user.user.email);
        console.log("accessTOken = ", user.accessToken);
        this.props.socialMediaLogin( // this is my method that I call on successful  authentication
          user.user.id,
          user.user.name,
          user.user.givenName,
          user.user.familyName,
          user.user.email,
          user.user.photo,
          "GOOGLE",
          user.accessToken
        );
      })
      .catch(err => {
        console.log("WRONG SIGNIN", err);
      })
      .done();
  }
like image 41
kaushal Avatar answered Oct 06 '22 01:10

kaushal


I just unblocked myself after struggling with this for almost 6 hours and here are my findings.

Please make sure the following:

  1. Correct package name in Google Developer console. (Don't go with just the package name from AndroidManifest.xml. Inspect the Gradle files to see if you flavor name is being changed dynamically when building).

  2. Generate Sha-1 Hash at the correct keystore location. (I was going with default keystore location ~/.android/debug.keystore but found out that my app was overriding with another location in the repository and hence, i was getting developer_error all along.)

PS: In case of your app uses backend server to pull data offline, create the project from the Google sign-in flow since this will generate OAuth Client id's for both Android and WebServer.

like image 22
TrueBlue Avatar answered Oct 06 '22 02:10

TrueBlue


For Windows

For windows use this keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users[YOUR WINDOWS USER NAME].android\debug.keystore

Like this

keytool -exportcert -list -v -alias androiddebugkey -keystore "Your debug.keystore" Path

keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\keshav.gera.android\debug.keystore

keytool -exportcert -list -v -alias androiddebugkey -keystore E:\HNSetup2\healthnickel\HealthNickel\android\app\debug.keystore

Password is :- android

enter image description here

ass your SHA1 Here Firebase Console

enter image description here

Note ===> update your google-service.json file in your app folder Please update

like image 41
Keshav Gera Avatar answered Oct 06 '22 01:10

Keshav Gera


My problem was the SHA1 key in the developer console didn't match the one generated from my debug.keystore file. Run

keytool -exportcert -keystore path-to-debug-or-production-keystore -

Copy the SHA1 key and paste it into the developer console (console.developers.google.com) under your app > credentials > OAuth 2.0 client IDs > Oauth > Signing-certificate fingerprint

like image 39
Mike Miller Avatar answered Oct 06 '22 00:10

Mike Miller