Google authentication code 12501

I use these following lines of code to integrate with G + android embed.

In the build.gradle application:

compile 'com.google.android.gms:play-services-auth:8.4.0' compile 'com.google.android.gms:play-services-plus:8.4.0'

In MainActivity:

  GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestIdToken("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com") .requestProfile() .build(); AppCompatActivity appCompatActivity = (AppCompatActivity) context; googleApiClient = new GoogleApiClient.Builder(context) .enableAutoManage(appCompatActivity, this) .addConnectionCallbacks(this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .addApi(Plus.API) .build(); 

I also added the google-services.gson file at the application level. I also made a web application and used client-id for the requestIdToken () parameter.

requestIdToken (webapp client identifier).

After writing this code, still I get status code = 12501 in the response and tokenId = null.

I also read this link . But can not find any solution.

+5
source share
3 answers

You need to add credentials for both your signed and client_id debugging in google-services.json as follows:

 "oauth_client": [ { "client_id": "<your-client-id>", "client_type": 1, "android_info": { "package_name": "<your-package-name>", "certificate_hash": "<hash>" } }, { "client_id": "<your-client-id-2>", "client_type": 1, "android_info": { "package_name": "<your-package-name-2>", "certificate_hash": "<hash-2>" } } ] 
+11
source

This may be due to the release of Sha-1 and Sha-256 and mismatch of debug keys.

Add all three keys (Debug: Sha-1, Release: Sha-1 and Sha-256) to the Firebase console, then reload json and replace.

It works great for me.

Sometimes OAuth 2.0 client identifiers (web application key) may not match

0
source

Make sure you include the following in your manifest file:

 <application ...> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> <!-- if app is a game --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
0
source

Source: https://habr.com/ru/post/1239834/


All Articles