![](/img/trans.png)
[英]identity server4 getting "invalid_grant" error for the connect/token endpoint when deployed to production
[英]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
的内容类型。
使其成为HTTPPOST请求而不是浏览器的HTTPGET请求
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.