【问题标题】:IdentityServer3 - post request for access token with hybrid flow?IdentityServer3 - 使用混合流发布访问令牌请求?
【发布时间】:2018-01-29 06:55:27
【问题描述】:

这是一项非常简单的任务,但由于我对 OIDC 和安全性也很陌生,这让我感到困惑。

我有 IdentityServer3 的实例和在服务器上创建的客户端。它利用混合流。我知道这是隐式和身份验证代码流之间的东西,所以我假设我可以使用授权代码或隐式授权类型,但显然不是。请问如何通过邮递员获取访问令牌?

我目前的要求:

  • client_id:sch
  • client_secret:testKey
  • grant_type:authorization_code
  • 范围:openid profile offline_access 电子邮件

我目前的回应: {

"error": "invalid_scope"

}

提前致谢。

【问题讨论】:

    标签: authentication oauth-2.0 identityserver3 hybridauth openid-connect


    【解决方案1】:

    您是否为您的客户指定了 AllowedScopes

    AllowedScopes = new List<string>
    {
        "openid", "profile", "otherScopes"
    }
    

    或者你现在可以只允许所有范围

    AllowAccessToAllScopes = true
    

    要从 Postman 获取访问令牌,您需要先为 postman 设置客户端,使用 AuthorizationCode Flow 为它

    new Client
    {
        ClientName = "Postman",
        ClientId = "postman",
        Flow = Flows.AuthorizationCode,
        AccessTokenLifetime = 43200,
        RedirectUris = new List<string>
        {
            "https://www.getpostman.com/oauth2/callback"
        },
        ClientSecrets = new List<Secret>
        {
            new Secret("secret".Sha256())
        },
        AllowAccessToAllScopes = true
        RequireConsent = false
    }
    

    现在在 Postmant 中获取令牌

    • 转到“授权”选项卡
    • 选择类型 OAuth 2.0
    • 点击获取新的访问令牌按钮
    • 填写这些字段
    • 点击请求令牌

    授权网址:https://yourIdenityServerAddress/identity/connect/authorize

    令牌网址:https://yourIdenityServerAddress/identity/connect/token

    【讨论】:

      猜你喜欢
      • 2018-08-22
      • 2016-06-15
      • 2019-12-03
      • 2015-09-15
      • 1970-01-01
      • 2019-02-19
      • 2015-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多