状态代码12501通过Google登录进行身份验证 [英] Status code 12501 authenticating with google sign-in

查看:203
本文介绍了状态代码12501通过Google登录进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在应用程序build.gradle中:
$ b
使用下面的代码行进行G + $ b

compile'c​​om.google.android.gms:play-services-auth:8.4.0'
compile'c​​om.google.android.gms:play-services-plus :8.4.0'



在MainActivity中:

 <$ 
.requestIdToken(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com)
.requestProfile()
。建立();

AppCompatActivity appCompatActivity =(AppCompatActivity)上下文;

googleApiClient =新的GoogleApiClient.Builder(上下文)
.enableAutoManage(appCompatActivity,this)
.addConnectionCallbacks(this)
.addApi(Auth.GOOGLE_SIGN_IN_API,gso)
.addApi(Plus.API)
.build();

我还在应用程序级别添加了google-services.gson文件。
我也制作了web应用程序,并使用clientId作为requestIdToken()参数。
$ b

requestIdToken(webapp的客户端ID)。



写完这段代码之后,我仍然收到状态码= 12501,tokenId = null。

我还阅读了此链接。但找不到任何解决方案。

解决方案

您需要为签名和调试 client_id google-services.json 这样的文件: 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>
}
}
]


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.

解决方案

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>"
    }
  }
]

这篇关于状态代码12501通过Google登录进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆