使用Play服务7.5.+登录后无法获取身份验证令牌(Android) [英] Unnable to get auth token after sign in with play services 7.5.+ (Android)

查看:147
本文介绍了使用Play服务7.5.+登录后无法获取身份验证令牌(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的Pl​​ay服务更新到7.5.0版之后,在执行google +登录后,我无法检索身份验证令牌以使用后端对应用进行身份验证.

After updating my play services to the version 7.5.0, I have problems retrieving the authentication token to authenticate the app with my backend after doing the google+ sign in.

我正在遵循 Android的Google登录中的文档.如前所述,登录有效,要求我在设备拥有多个设备时选择一个帐户,并允许该应用程序使用权限,然后我尝试通过异步任务获取令牌:

I'm following the documentation at Google Sign-In for Android. As said, the sign in works, I'm requested to select an account when the device has more than one, and to allow permissions for this app, and after that I try to get the token with an async task:

 protected String doInBackground(String... params) {
    String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    String scopes = "audience:server:client_id:" + SERVER_CLIENT_ID; // Not the app's client ID.
    String idToken = "";
    try {
        idToken = GoogleAuthUtil.getToken(getApplicationContext(), account, scopes);
    } catch (IOException e) {
        Log.e(TAG, "Error retrieving ID token.", e);
    } catch (GoogleAuthException e) {
        Log.e(TAG, "Error retrieving ID token.", e);
    }
    return idToken;
}

我总是收到未知的GoogleAuthException .我很确定我使用的是正确的SERVER_CLIENT_ID,并且已在Google Developer Console中正确配置了该SERVER_CLIENT_ID(因为它可以与以前版本的播放服务一起正常使用).

I receive always a GoogleAuthException Unknown. I'm pretty sure that I'm using the right SERVER_CLIENT_ID, and that this SERVER_CLIENT_ID is well configured in the Google Developer Console (because this was working right with the previous version of the play services).

还有其他人有这个问题吗?

Anybody else is having this problem?

谢谢!

推荐答案

我自己解决了这个问题.

I solved the problem my self.

新工具可以为播放服务为您的应用程序启用google服务,提供了一个向导,该向导可生成一个json文件,我们必须将该json文件包含到我们的项目中.

The new tool that generates a configuration file for the play services Enabling google services for your app, offers a wizard that generate a json file that we have to include into our project.

问题在于,从组合框中选择应用程序后,向导会自动建议"com.mydomain"作为android程序包名称,但正确的程序包名称是"com.mydomain.app".

The problem was that after choosing the app from the combo box, the wizard automatically suggested "com.mydomain" as android package name, but the right package name was "com.mydomain.app".

因此,建议您再次查看google-services.json文件中的软件包名称.

So the advice is take a second look to the package name in the google-services.json file.

我觉得这很难调试!

这篇关于使用Play服务7.5.+登录后无法获取身份验证令牌(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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