0

我刚刚开始了解身份模型,并一直在查看此处的示例 - https://identitymodel.readthedocs.io/en/latest/client/token.html

我正在查看最简单的示例 - 使用 client_credentials 授予类型请求令牌 - 并使用示例代码,我将一些简单的 vb.net 放在一起进行测试和试验。

我遇到的问题是我只收到了 invalid_client 错误消息。

我敢肯定,我错过了一些显而易见的事情,但如果有人能指出我正确的方向,那将非常有帮助。

Dim request As New ClientCredentialsTokenRequest
request.Address = "https://demo.identityserver.io/connect/token"
request.ClientId = "client"
request.ClientSecret = "secret"
request.Scope = "api1"

Dim client As New HttpClient        
Dim response As TokenResponse = Await client.RequestClientCredentialsTokenAsync(request)
4

1 回答 1

0

如@abdusco 的回复所示,正确的代码应如下所示

Dim request As New ClientCredentialsTokenRequest
request.Address = "https://demo.identityserver.io/connect/token"
request.ClientId = "m2m"
request.ClientSecret = "secret"
request.Scope = "api"

Dim client As New HttpClient        
Dim response As TokenResponse = Await client.RequestClientCredentialsTokenAsync(request)

感谢您的帮助。

于 2021-07-12T12:17:34.777 回答