尝试获取范围com.google.api.server.spi.config.scope.SingleAuthScope

Tried and failed to get client id for scope com.google.api.server.spi.config.scope.SingleAuthScopeExpression

本文关键字:spi server config scope SingleAuthScope api google 获取 范围 com      更新时间:2023-09-26

在Google Cloud endpoint迁移时间表中,描述了从其他身份验证服务迁移的步骤,其中写道https://www.googleapis.com/auth/userinfo.email作用域已被弃用,并且应该考虑迁移到email作用域(类似于userinfo)。 profile scope)。

在Java类Constants中,其中定义了像Client ID这样的常量,用于我的@Api服务类,我更改了

public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";

public static final String EMAIL_SCOPE = "email";

同样在客户端JavaScript的例子形式谷歌,我改变范围变量为

var scopes = 'email';

和在谷歌开发者控制台日志我得到以下例外:

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 参数中的

a null是由引擎插入的(当然我是被授权的)。

即使我将作用域更改为profile,这也不起作用。它只适用于localhost,但我认为,这不是问题。

有人可能会问,为什么你可以让它作为userinfo.email呢?我正在寻找一些其他的范围,因为偶尔一些特定的谷歌用户(我不知道什么是具体的关于他们),userinfo。email也不工作。有人能帮帮我吗?谢谢。

您不需要更新作用域。