[英]OAuth2 token with google play services on Android
我正在尝试使用 Google Play 服务为 Android 上的 Google Cloud Storage 获取 Oauth2 令牌。 我正在使用以下代码
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) {
}
这会引发 GoogleAuthException。 Google PLAy 服务目前不支持此范围吗??
在向 GoogleAuthUtil 询问 OAuth2 令牌时,您需要使用字符串“oauth2:”作为范围的前缀。 如果您想要多个范围,您可以使用空格分隔符列出它们。
因此,在您的情况下,范围字符串将是“oauth2:https://www.googleapis.com/auth/devstorage.read_only”。
有关更多详细信息,请参阅http://android-developers.blogspot.com/2012/09/google-play-services-and-oauth-identity.html 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.