我有android,google授权问题(类似于.GoogleAuthException: Unknown while doing Google SSO.-无答案):
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)
当我执行以下代码时,它是可复制的:
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);
这里有一些注意事项:
android.permission.GET_ACCOUNTS
解决了
即像这样:
} catch (UserRecoverableAuthException e) {
activity.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
}
最佳答案
在Google Developer Console中的“API和身份验证”部分中,单击“凭据”。
您可能已经有一个“Android应用程序的客户端ID”,并且正在使用该客户端ID。您需要做的是创建一个新的客户端ID,然后为您的后端选择“服务帐户”。
您必须使用此客户端ID,而不是Android。