Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status code 12501 authenticating with google sign-in

I am using these below lines of code for G+ sign-in android integration.

In app build.gradle :

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 have also added "google-services.gson" file at app level. I have also made web-application and use client-id for requestIdToken() parameter.

requestIdToken(client-id of webapp).

After writing this code, Still I am getting status code = 12501 in response and tokenId = null.

I have also read this link. But Can not find any solution.

like image 599
Akashsingla19 Avatar asked Jan 04 '16 21:01

Akashsingla19


1 Answers

You need to add the credentials for both your signed and debug client_id in the google-services.json file like this:

"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>"
    }
  }
]
like image 196
gerardnimo Avatar answered Oct 20 '22 00:10

gerardnimo