Error 12501 authentication using google login

I use google login services to authenticate users who use my application. I got it for work when I just requested information by email.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail().build(); 

Then I realized that I also needed to request an ID token in order to be able to authenticate with my backend, so I did:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(String.valueOf(R.string.server_client_id)) .requestEmail().build(); 

The problem is that he did not allow me to log in after the changes. The status that I get every time I try to log in is Status{statusCode=unknown status code: 12501, resolution=null} .

I searched around and I found this post , which pretty much applies to the same. However, I did not make mistakes called by the people who responded, the OAuth client ID in my developer console is for the web application: clientIDs And R.string.server_client_id is the first client identifier in the picture. package names, of course, are correct in all placed ones, otherwise it will not even work without a token request. 2 people also suggested that the application be signed for this, but the googles documentation says that the debug key should work too, and it makes no sense to get people to sign applications for debugging.

I tried to figure it out for hours, but to no avail. What could be the problem? Please feel free to request additional information that I may have forgotten to put here.

+46
android google-play-services google-signin google-identity
Nov 21 '15 at 18:06
source share
12 answers

Well, this is very awkward, but I realized this:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(AuthenticatedActivity.this.getResources().getString(R.string.server_client_id)) .requestEmail().build(); 

I sent him a resource identifier instead of a dereferenced string resource.

+22
Nov 22 '15 at 11:34
source share

Obviously, first check that your sha1 key is correct for release. But if it still does not work, and you use google play 8.4.0 services (iecompile 'com.google.android.gms: play-services: 8.4.0'), the problem can be solved by modifying the GoogleSignInOption object. Instead:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestIdToken("YOUR_WEB_API_ID.apps.googleusercontent.com") .build(); 

You should use:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)) .requestScopes(new Scope(Scopes.PLUS_ME)) .requestEmail() .build(); 

This solves the error returning statusCode = INTERNAL_ERROR OR statusCode = Error 12501 OR statusCode = Error 12500. Then this gso object can be used to create GoogleApiClient, as shown below:

  mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API,gso) // .addApi(Plus.API, null) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) // .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); 

See below for more details: Google is not working on version of android version

+10
Apr 12 '16 at 14:20
source share

In my project, I had a different application in my gradle file than in packagename in my manifest.xml, and this caused my problem.

The android key that I was supposed to create had to have applicationId fqdn and NOT the package name (contrary to what Google says) for it to work for me.

Thought I'd leave it here if it saves someone time.

+3
Dec 17 '15 at 21:19
source share

1.Save signature in gradle file

 signingConfigs { config { keyAlias 'appalias' keyPassword 'hunter123' storePassword 'hunter123' storeFile file('path/to/keystore.jks') } } 

2.Go to create types in the project structure (in Android Studio) and specify that signedConfigs for "config"

Now clean your project and create it again. It should work.

If the above does not work, then below is the last. Try the first step and build and validate. If it does not work, go to the next step and try to build again.

  • Create a signed apk (with password confirmation).
  • Before signing, check the name of the keystore file and the one that you give when signing apk (in android studio).
  • Install the signed apk on your device.
  • Wait five minutes.
  • Try singing on google. If 12501 still occurs, wait another five minutes. By doing this gradle combination.
  • Try again. It should work.

Edit: Google added apk subscription in console. If you have already signed your apk, ignore it OR if you want to use it, be careful with it, because it may violate your current Google login settings

+3
Mar 30 '17 at 6:22
source share

I had this problem when I accidentally used the Android application client identifier instead of Webapp as the requestIdToken() parameter.

Use the Webapp client ID here. By default, it is called Web client (auto created by Google Service)

+3
Apr 26 '17 at 12:09 on
source share

Have you already configured signingConfigs and buildTypes in your Gradle? I fixed it by explicitly pointing those things to gradle. Read here http://developer.android.com/tools/publishing/app-signing.html

+1
Dec 27 '15 at 2:38
source share

Make sure you add the SHA-1 fingerprint for your key (release) under Firebase console

Find your SHA1 key : keytool -exportcert -list -v -alias <your-key-name> -keystore <path-to-production-keystore>

Add it to the firebase console: go to https://console.firebase.google.com , select your application, select settings.

enter image description here

+1
May 24 '17 at 1:25 p.m.
source share

I had the same problem. The problem was that I somehow selected the wrong “API Project” and therefore chose the wrong web client key. Obviously, there were two OAuth2 server client identifiers created in both of my API projects, while my attempts were to run a demo application.

configuration view

+1
May 25 '17 at 11:11
source share

I had a similar problem. In my case, this happened because the server client identifier that I used was from a project other than client ones. It turns out they should be from the same project.

0
Feb 12 '16 at 13:41
source share

Hi, I saw the comments above, but as I did practically, its all sha problems, means that if you register the sha of a specific ip address and get google.services json, it will improve or you can use

  gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); 

or gso = new GoogleSignInOptions.Builder (GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken (LoginActivity.this.getResources (). GetString (R.string.server_client_id)) .requestEmail () build (). but if you want to create the application on a different ip address with a different machine sha, you will see error status code 12501, so for this you need to create sha again for this particular machine. thank

0
May 22 '17 at 8:40
source share

<meta-data> of Androidmanifest.xml is outside the <application></application> shell. That is why you get error 12501

  <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> 
0
Apr 01 '18 at 21:12
source share

I do not know how relevant this issue is in 2019. However, error code 12501 means:

Login has been canceled by user. those. the user has canceled some of the entries in the resolution, such as account selection or OAuth consent.

Check out the following link for more information:

https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInStatusCodes.html#SIGN_IN_CANCELLED

0
Jul 09 '19 at 5:53 on
source share



All Articles