无法获取授权code与Google+登录功能对于Android:INVALID_SCOPE功能、Google、code、Android

2023-09-06 03:14:25 作者:来去四方

我试图获取授权code以下的这说明。服务器的客户端ID赞同我的Andr​​oid客户端ID在同一个项目。

I am trying to retrieve an authorization code to use in my server side following these instructions. The client ID of the server shares the same project of my Android Client ID.

我可以检索访问令牌,而不是授权code:

I can retrieve the access token, but not the authorization code:

String mScopes = "oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email";
//String mScopes = "oauth2:server:client_id:314345278679.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email";
Bundle mAppActivities = new Bundle();
mAppActivities.putString(GoogleAuthUtil.KEY_REQUEST_VISIBLE_ACTIVITIES, "");
String authorizationToken = GoogleAuthUtil.getToken(LoginActivity.this, mPlusClient.getAccountName(), mScopes, mAppActivities);

取消注释使用替代范围(检索授权code,而不是一个令牌)产生以下错误:

Uncommenting to use the alternative scope (to retrieve an authorization code instead of a token) produces the following error:

I/GLSUser (15293): GLS error: INVALID_SCOPE my_email_address@company.com oauth2:server:client_id:314345278679.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email

任何想法?

推荐答案

您错过的https://www.googleapis .COM /认证/ plus.login 从你的作用域。我想你的code和获得INVALID_SCOPE没有plus.login,但它工作正常。

You're missing https://www.googleapis.com/auth/plus.login from your scopes. I tried your code and get INVALID_SCOPE without plus.login, but it works fine with.