codeninja.sj
codeninja.sj

Reputation: 4139

How to get id_token from TokenEndpoint of IdentityServer4 through authorization_code flow?

I would like to get "access_token" and "id_token" from Token endpoint through Authorization Code flow. But, I am getting "invalid_grant" error while calling the token endpoint with following parameters on postman.

POST /connect/token HTTP/1.1
Host: localhost:2000
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: a8a29659-0ea3-e7dc-3bd6-6e6630a7370d

client_id=client
&client_secret=client
&grant_type=authorization_code
&username=admin
&password=admin
&scope=openid+profile

Client Configuration:

new Client
{
   ClientId = "client",
   ClientSecrets =
   {
     new Secret("client".Sha256())
   },
   AllowedGrantTypes = new List<string> { OidcConstants.GrantTypes.AuthorizationCode },
   AllowedScopes = {
     StandardScopes.OpenId.Name,
     StandardScopes.Profile.Name,
   }
}

What is wrong in my client configuration section? and, How do i make a successful post request to Token Endpoint?

Upvotes: 0

Views: 578

Answers (1)

Spomky-Labs
Spomky-Labs

Reputation: 16775

The authorization code grant type requires a code parameter to be sent during the token request (see RFC6749 section 4.1.3).

This code is issued by the authorization server after the resource owner authorized the client (see RFC6749 section 4.1.2).

Upvotes: 2

Related Questions