【问题标题】:How do I retrieve OpenID 2.0 identifier (openid_id) when using Apache Oltu with Google OpenID Connect将 Apache Oltu 与 Google OpenID Connect 结合使用时,如何检索 OpenID 2.0 标识符 (openid_id)
【发布时间】:2015-05-29 12:31:44
【问题描述】:

在将 Apache Oltu 与 Google OpenID Connect 结合使用时,如何检索 OpenID 2.0 标识符 (openid_id)。

这是我正在使用的授权请求:

OAuthClientRequest oltu_request = OAuthClientRequest.authorizationProvider(OAuthProviderType.GOOGLE)
                                        .setClientId(CLIENT_ID)
                                        .setResponseType(OAuth.OAUTH_CODE)
                                        .setParameter("access_type", "offline")
                                        .setScope("https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email")
                                        .setRedirectURI("https://app.com/sso_return")
                                        .buildQueryMessage();

【问题讨论】:

    标签: oauth-2.0 google-oauth google-openid openid-connect oltu


    【解决方案1】:

    使用额外的:

    .setParameter("openid.realm", "<realm>")
    

    OpenID 2.0 标识符将在 ID 令牌的 openid_id 声明中返回。见:https://developers.google.com/accounts/docs/OpenID#openid-connect

    【讨论】:

    • 汉斯,谢谢!我补充说。在 Google 重定向回我之后,我现在如何检索 OpenID 标识符?示例代码?谢谢! :)
    • 你会使用类似tokenResponse.getIdToken().getClaimsSet().getCustomField("openid_id", String.class)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    • 1970-01-01
    • 1970-01-01
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多