【问题标题】:Tried and failed to get client id for scope com.google.api.server.spi.config.scope.SingleAuthScopeExpression尝试获取范围 com.google.api.server.spi.config.scope.SingleAuthScopeExpression 的客户端 ID,但未能成功
【发布时间】: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 也不起作用。 有人可以帮我吗?谢谢。

【问题讨论】:

标签: java javascript oauth-2.0 google-apps google-cloud-endpoints


【解决方案1】:

您不需要更新范围。即使该范围已被弃用,也不会被删除。

【讨论】:

    猜你喜欢
    • 2023-02-08
    • 2014-12-18
    • 2019-02-20
    • 2019-08-15
    • 2019-08-02
    • 2012-03-28
    • 2015-03-11
    • 2021-05-23
    • 1970-01-01
    相关资源
    最近更新 更多