14

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 ?

Prashant
  • 3,934
  • 4
  • 30
  • 65
  • As the error documentation says "Your app is misconfigured". If you want to use debug keystore, then make sure sha-1 is created using debug keystore only. – Deepak Singh Oct 17 '16 at 14:26
  • 1
    Yes I did that using : keytool -exportcert -list -v -alias androiddebugkey -keystore C:/MyProjects/ProjectDir/app/debug.keystore – Prashant Oct 17 '16 at 14:29

8 Answers8

26

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

Prince Dholakiya
  • 3,017
  • 23
  • 38
Prashant
  • 3,934
  • 4
  • 30
  • 65
  • 2
    and also need to add buildTypes{debug{signingConfig signingConfigs.debug}} in the file – Murtuza Jan 11 '18 at 11:22
  • **To retrieve correct SHA1** `keytool -exportcert -list -v -alias androiddebugkey -storepass android -keystore android/app/debug.keystore` (with your keystore path) – Guglie Jul 18 '20 at 17:10
12

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

Dave Kerr
  • 4,419
  • 2
  • 24
  • 28
  • 2
    running this command "keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore" gives error: keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified. – ozmank Jul 24 '18 at 09:16
  • For windows use this `keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\[YOUR WINDOWS USER NAME]\.android\debug.keystore` – Shakti Jun 06 '19 at 08:52
  • **To skip password input** `keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android` – Guglie Jul 18 '20 at 17:12
6

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();
  }
kaushal
  • 747
  • 9
  • 14
  • Thank you for the detailed answer. I did all these things and I still just get DEVELOPER_ERROR when running `GoogleSignIn.signIn()`. It's incredible. Why isn't there a better error message? – Iguananaut Apr 06 '20 at 18:48
  • 1
    Did you check your client_id is that correct? I don't think that error will come when your client id is correct. Because I add the same code 3-4 times. – kaushal Apr 14 '20 at 06:09
  • thank you for confirming that; I did figure this out a few days ago and that was indeed the problem. Would it kill them to give a more useful error though? :) – Iguananaut Apr 16 '20 at 11:24
  • where should i paste the copied webclient id? – Rahul Shakya Nov 04 '20 at 05:29
  • @RahulShakya Sorry for my delayed respone. You can make a constant for that `webClientID` and use that. – kaushal Dec 21 '20 at 10:48
5

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

Keshav Gera
  • 8,200
  • 1
  • 56
  • 43
4

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

Mike Miller
  • 2,913
  • 4
  • 31
  • 44
  • This seems outdated, I cannot see "Signing-certificate fingerprint" in the console. – dom96 Jul 04 '20 at 21:00
  • oh, this is specifically only for a Outh Client ID with a "Android" type. I was using a Web App type client ID (it works when running from Android Studio but not when installed from Play :/) – dom96 Jul 05 '20 at 11:33
3

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.

TrueBlue
  • 301
  • 3
  • 5
0

Another thing to watch is that newer versions of keytool (eg for Java 9) will generate a SHA-256 value, not SHA-1.

-1

In my case I was using the wrong SHA-1

In my case I was using this

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

for SHA-1.

When I used this keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

and pasted the SHA-1 in firebase console it worked

mzparacha
  • 506
  • 5
  • 18