Search code examples
asp.netvb.netidentitymodel

Identity Model invalid_client


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)

Solution

  • 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.