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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With