Reputation: 19416
I'm attempting to get a Oauth2 token for Google Cloud Storage on Android using Google Play services. I am using the following code
try {
gsToken=GoogleAuthUtil.getToken(this, email,
"https://www.googleapis.com/auth/devstorage.read_only");
} catch (IOException e) {
e.printStackTrace();
} catch (UserRecoverableAuthException userAuthEx) {
startActivityForResult(userAuthEx.getIntent(),1);;
} catch (GoogleAuthException e) {
}
This throws a GoogleAuthException. Is this scope not supported at this time by Google PLay Services??
Upvotes: 2
Views: 3043
Reputation: 496
You need to prefix the scope with the string "oauth2:" when asking GoogleAuthUtil for OAuth2 tokens. If you want multiple scopes you can list them with a space separator.
So, in your case the scope string would be "oauth2:https://www.googleapis.com/auth/devstorage.read_only".
For more details see http://android-developers.blogspot.com/2012/09/google-play-services-and-oauth-identity.html.
Upvotes: 2