繁体   English   中英

Identity Server4 连接/令牌端点给出 400 Bad Request

[英]Identity Server4 connect/token endpoint gives 400 Bad Request

我们将 EntityFrameworkCore 与 Identity Server4 一起使用。 初始设置后,身份服务器的发现端点( localhost:6000/.well-known/openid-configuration )工作正常。 当我们尝试从邮递员那里调用connect/token端点时,它给出了 400 个错误的请求响应。 这是我们的客户:

public static IEnumerable<Client> GetClients()
{
    return new List<Client>
    {
        new Client
        {
            ClientId = "client",

            // no interactive user, use the clientid/secret for authentication
            AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

            // secret for authentication
            ClientSecrets =
            {
                new Secret("secret".Sha256())
            },

            // scopes that client has access to
            AllowedScopes = { ApiResourceName.Sup_Api.Description() }
        },
        new Client
        {
            ClientId = "client2",

            // no interactive user, use the clientid/secret for authentication
            AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,

            // secret for authentication
            ClientSecrets =
            {
                new Secret("secret".Sha256())
            },

            // scopes that client has access to
            AllowedScopes = { "sup"}
        }
    };
}

这是邮递员连接/令牌发布请求:

http://localhost:6000/connect/token
  ?client_id=client2
  &client_secret=secret
  &grant_type=client_credentials
  &scope=sup

回应:

{
    "error": "invalid_request"
}

您不通过查询字符串传递参数。 它应该在正文中,使用application/x-www-form-urlencoded的内容类型。

参见: https : //tools.ietf.org/html/rfc6749#section-4.1.3

使其成为HTTPPOST请求而不是浏览器的HTTPGET请求

工作邮递员示例:

在此处输入图片说明

我不确定 redirect_uri 值。 但作为回应我得到:

  • id_token
  • 访问令牌
  • 刷新令牌

和其他一些。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM