Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get Authorization Code with Google+ Sign-in for Android: INVALID_SCOPE

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.

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);

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 [email protected] oauth2:server:client_id:314345278679.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email

Any ideas?

like image 812
Nacho Coloma Avatar asked Jun 18 '13 14:06

Nacho Coloma


People also ask

What is authorized JavaScript origins Google?

An origin is a unique combination of protocol, hostname, and port. In the Authorized JavaScript origins field, enter the origin for your app. You can enter multiple origins to allow for your app to run on different protocols, domains, or subdomains. You cannot use wildcards.

What is authorization code in oauth2?

The authorization code is a temporary code that the client will exchange for an access token. The code itself is obtained from the authorization server where the user gets a chance to see what the information the client is requesting, and approve or deny the request.

What is https oauth2 Googleapis com token?

https://accounts.google.com/o/oauth2/token. The response is JSON that contains both an access token and a refresh token. The refresh token is what you want because it allows you to request new access tokens and has a very long lifespan.


1 Answers

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.

like image 168
Lee Avatar answered Sep 28 '22 23:09

Lee