【发布时间】:2015-08-01 22:13:47
【问题描述】:
在 Google Cloud Endpoints migration timetable 中描述了从其他身份验证服务迁移的步骤,其中写道 https://www.googleapis.com/auth/userinfo.email 范围已不推荐使用,并且迁移到应考虑 email 范围(类似地从 userinfo.profile 范围到 profile 范围)。
在 Java 类 Constants 中为我的 @Api 服务类定义了诸如 Client ID 之类的常量,我更改了
public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
到
public static final String EMAIL_SCOPE = "email";
同样在 JavaScript example form google 的客户端,我将 scopes 变量更改为
var scopes = 'email';
在 Google Developers Console 日志中,我收到以下异常:
com.google.api.server.spi.auth.AppEngineAuthUtils getCurrentUser:
getCurrentUser: AccessToken; Tried and failed to get client id for scope 'com.google.api.server.spi.config.scope.SingleAuthScopeExpression@ed8e89a9'
com.google.appengine.api.oauth.InvalidOAuthParametersException:
at com.google.appengine.api.oauth.OAuthServiceImpl.makeSyncCall(OAuthServiceImpl.java:139)
在我的端点方法中
@ApiMethod(name = "authorize", httpMethod="get")
public AppUser authorize(User user) throws NonAuthorizedException {
...
}
在 User user 参数中,引擎插入了一个 null(我当然是被授权的)。
即使我将范围更改为 profile,这也不起作用。它仅适用于 localhost,但我认为,这不是问题。
有人会问,那你为什么就让它成为 userinfo.email?我一直在寻找其他一些范围,因为偶尔对于某些特定的谷歌用户(我不知道他们具体是什么), userinfo.email 也不起作用。 有人可以帮我吗?谢谢。
【问题讨论】:
-
会不会是这样:问题 8848 get_current_user API 未填写 user_id code.google.com/p/googleappengine/issues/detail?id=8848
标签: java javascript oauth-2.0 google-apps google-cloud-endpoints