我们正在将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"}
}
};
}
这是postman连接/令牌发布请求:
http://localhost:6000/connect/token
?client_id=client2
&client_secret=secret
&grant_type=client_credentials
&scope=sup
响应:
{
"error": "invalid_request"
}
答案 0 :(得分:7)
您不通过查询字符串传递参数。它的意思是在身体中,使用内容类型application/x-www-form-urlencoded
。
答案 1 :(得分:0)
答案 2 :(得分:0)
将其设为 HTTPPOST 请求,而不是浏览器的HTTPGET请求