【问题标题】:WSO2 Implicit Flow not returning id_tokenWSO2 隐式流不返回 id_token
【发布时间】:2017-06-20 04:29:32
【问题描述】:

我正在尝试使用 WSO2 中的 OpenID Connect 服务提供商从自定义 Web 应用程序验证用户。我正在关注this article 上的答案,并添加了 Nuget 包 Thinktecture.IdentityModel.Client。我的代码与链接的文章非常相似:

 var client = new OAuth2Client(new Uri(serviceProviderAuthorizeUrl));

        var url = client.CreateImplicitFlowUrl(
            clientId,
            redirectUri: redirectUrl,
            scope: scope,
            nonce: Guid.NewGuid().ToString());

        Response.Redirect(url);

网址是:https://{wso2_url}/oauth2/authorize?client_id={my_client_id}&response_type=token&scope=openid&redirect_uri=https%3A%2F%2F{mydomain}%2F{my_app}%2FCallback.aspx&nonce=f0db4eac-18df-46f6-92f1-c28ba621596d

现在这确实有效并返回了一个 access_token:https://{my_domain}/{my_app}/Callback.aspx#token_type=Bearer&expires_in=970&access_token=067e3366217798986912326a86abd92f

我的问题是我不知道用户是谁。此外,这个WSO2 article 表明,如果我传递了 response_type:id_token 我应该能够解码响应并使用“sub”属性找出用户是谁,但我没有得到 id_token 响应。上面的代码创建了一个带有 response_type 令牌的 url。只需更改 response_type 就会给我一个错误。如何在 WSO2 中使用隐式流并获取 id_token 响应?

我按照article 进行了 WSO2 的配置。我目前已检查隐式和客户端凭据。

【问题讨论】:

    标签: wso2 wso2is openid-connect


    【解决方案1】:

    确保您将这些作为查询参数。

    response_type=id_token
    client_id=xxxxx
    redirect_uri=http://xx.com/xx/x
    nonce=xxxx
    scope=openid
    

    【讨论】:

    • CreateImplicitFlowUrl 不接受 response_type 的参数。我也试过这个:var url = serviceProviderAuthorizeUrl + "?response_type=" + HttpUtility.UrlEncode(responseType) + "&client_id" + HttpUtility.UrlEncode(clientId) + "&redirect_uri=" + HttpUtility.UrlEncode(redirectUrl) + "&nonce=" + HttpUtility.UrlEncode(Guid.NewGuid().ToString()) + "&scope=" + HttpUtility.UrlEncode(scope); Response.Redirect(url); 并将 id_token 作为 response_type 传递,我收到了来自 WSO2 的错误。我希望事情就这么简单,但事实并非如此。
    【解决方案2】:

    确保传递旨在用于 Idp (WSO2) 的范围,以了解它需要返回哪些数据。确保你的范围 范围=openid。

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2015-06-10
      • 1970-01-01
      • 2016-12-10
      • 2017-12-15
      • 2018-07-23
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      相关资源
      最近更新 更多