Android上带有google play服务的OAuth2令牌

Android上带有google play服务的OAuth2令牌,android,oauth-2.0,google-cloud-storage,google-play-services,Android,Oauth 2.0,Google Cloud Storage,Google Play Services,我正在尝试使用Google Play服务为Android上的Google云存储获取Oauth2令牌。我正在使用以下代码 try { gsToken=GoogleAuthUtil.getToken(this, email, "https://www.googleapis.com/auth/devstorage.read_only"); } catch (IOException e) { e.printStackTrace();

我正在尝试使用Google Play服务为Android上的Google云存储获取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) {

    }

这引发了一个异常。Google PLay Services目前不支持此作用域吗?

当向GoogleAuthUtil询问oauth2令牌时,需要在作用域前面加上字符串“oauth2:”。如果需要多个作用域,可以使用空格分隔符列出它们

因此,在您的情况下,作用域字符串将是“oauth2:https://www.googleapis.com/auth/devstorage.read_only“


有关更多详细信息,请参见。

Hey@jham,这曾经对我有效,但就在几天前它停止工作,现在抛出此错误com.google.android.gms.auth.GoogleAuthException:未知。知道为什么吗?我的示波器有问题吗?嘿,我遇到了完全相同的问题,GoogleAuthUtil.getToken以前工作正常,最近它开始出现未知异常。你找到解决办法了吗?