0

I am just starting to learn about identity model and have been looking at the examples here - https://identitymodel.readthedocs.io/en/latest/client/token.html

I'm looking at the simplest example - Requesting a token using the client_credentials Grant Type - and using the example code I have put together some simple vb.net to test and experiment with.

The problem I am getting is that I only ever get back an invalid_client error message.

I'm sure it is something obvious that I am missing but if someone could point me i the right direction that would be immensely helpful.

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)
Mike
  • 45
  • 7
  • 1
    Does the client have permission to request `api1` scope? There's only `api` scope listed in [id server demo page](https://demo.identityserver.io/). You need to change `api1` -> `api` – abdusco Jul 12 '21 at 11:05
  • Thanks for the link to the id server demo page. You were indeed correct that api1 should be api. Also i had the client id wrong, needed to be 'm2m' – Mike Jul 12 '21 at 12:14

1 Answers1

0

As indicated in the reply by @abdusco the correct code should look like

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)

Thank you for the help.

Mike
  • 45
  • 7