0

我正在尝试使用 Android 应用程序为我的 Web 后端获取授权代码。根据跨客户端授权文档,我应该使用如下所示的范围调用GoogleAuthUtil.getAuthToken()oauth2:server:client_id:<back-end client id>:api_scope:resource-1 resource-2 是我形成范围的方式:

private String getOAuthScope() {
    final String scope = "email openid";
    return String.format("oauth2:server:client_id:%s:api_scope:%s",
                         GoogleOAuthData.GOOGLE_OAUTH_SERVER_CLIENT_ID, scope);

当我打电话时GoogleAuthUtil.getAuthToken(),我得到一个INVALID_SCOPE例外。形成范围的正确方法是什么?

4

1 回答 1

0

I initially thought you were using incorrect scope names (e.g "email" rather than "https://mail.google.com/") but according to https://developers.google.com/accounts/docs/OAuth2Login the names are correct for that specific use. However, it looks like the expected scope string is "openid, email" not "email openid".

A source of the "Unknown" exception is if your server and client are not part of the same APIs console project.

于 2013-11-26T20:27:06.837 回答