GoogleAuthException:未知(机器人) [英] GoogleAuthException: Unknown (android)

查看:263
本文介绍了GoogleAuthException:未知(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有机器人,谷歌授权的问题(类似<一个href="http://stackoverflow.com/questions/17906699/googleauthexception-unknown-while-doing-google-sso">.GoogleAuthException:未知的,而这样做谷歌SSO - 无答案):

  09-29 00:04:38.328:W / System.err的(15623):com.google.android.gms.auth.GoogleAuthException:未知
09-29 00:04:38.328:W / System.err的(15623):在com.google.android.gms.auth.GoogleAuthUtil.getToken(来源不明)
 

这是可再现的,当我执行下面的code:

 字符串scopesString = Scopes.PLUS_LOGIN ++ Scopes.PLUS_PROFILE;
字符串范围=oauth2:服务器:CLIENT_ID:+ Consts.GOOGLE_PLUS_SERVER_CLIENT_ID +:api_scope:+ scopesString;
要么
字符串范围=观众:服务器:CLIENT_ID:+ Consts.GOOGLE_PLUS_SERVER_CLIENT_ID;
捆绑appActivities =新包();
appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIEShttp://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity);
GoogleAuthUtil.getToken(活动,帐户名,范围,appActivities);
 

下面是一些注意事项:

  1. 在我能访问令牌GoogleAuthUtil.getToken(活动,帐户名,oauth2:+ scopesString)
  2. 活动!= NULL,CLIENT_ID = 123456789.apps.googleusercontent.com,帐户名是有效的电子邮件(与帐户选择器中选择)
  3. 帐户名在 http://plus.google.com/u/0/apps 有一个关于纪录我的项目:其中,项目名称> -------应用程序和采购活动--------你的社交圈
  4. android.permission.GET_ACCOUNTS
  5. 同样异常appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES,)
  6. 同样异常GoogleAuthUtil.getToken(活动,帐户名,范围)

解决

  1. 您应该有2个客户Id:安装应用程序(Android版)以及服务之一。您应该使用服务的一个位置。
  2. 然后你会得到UserRecoverableAuthException:NeedPermission。你应该处理异常

即。像这样的:

 }赶上(UserRecoverableAuthException E){
activity.startActivityForResult(e.getIntent(),REQUEST_AUTHORIZATION);
}
 

解决方案

在谷歌开发者控制台,在原料药和放大器;验证部分,单击证书。

您可能已经有一个为Android应用程序客户端ID和正在使用的客户端编号。你必须要做些什么后端的创建一个新的客户端ID,然后选择服务帐户。

您必须使用该客户端ID,而不是Android的之一。

I have android, google authorization issue (similar to .GoogleAuthException: Unknown while doing Google SSO. - no answers):

09-29 00:04:38.328: W/System.err(15623): com.google.android.gms.auth.GoogleAuthException: Unknown
09-29 00:04:38.328: W/System.err(15623):    at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)

It is reproducable when i execute the following code:

String scopesString = Scopes.PLUS_LOGIN + " " + Scopes.PLUS_PROFILE;
String scopes = "oauth2:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID + ":api_scope:" + scopesString;
OR
String scopes = "audience:server:client_id:" + Consts.GOOGLE_PLUS_SERVER_CLIENT_ID;
Bundle appActivities = new Bundle();
appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "http://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity");
GoogleAuthUtil.getToken(activity,  accountName, scopes, appActivities);

Here are some notes:

  1. I can get access token with GoogleAuthUtil.getToken(activity, accountName, "oauth2:" + scopesString)
  2. activity != null, client_id = 123456789.apps.googleusercontent.com, accountName is valid email (selected with account picker)
  3. accountName in http://plus.google.com/u/0/apps has a record about my project: <Project Name> ------- app and purchase activity--------Your circles
  4. I have android.permission.GET_ACCOUNTS
  5. The same exception with appActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "")
  6. The same exception with GoogleAuthUtil.getToken(activity, accountName, scopes)

SOLVED

  1. You should have 2 Client Ids: Installed App (Android) and Service one. You should use Service one here.
  2. Then you will get UserRecoverableAuthException: NeedPermission. You should handle exception

i.e. like this:

} catch (UserRecoverableAuthException e) {
activity.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
}

解决方案

In the Google Developer Console, in the APIs & Auth section click Credentials.

You probably already have a "Client ID for Android application" and are using that Client ID. What you have to do is create a new Client ID and select "Service Account" for your backend.

You must use this Client ID, and not the Android one.

这篇关于GoogleAuthException:未知(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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