I'm using below code to consume JWT access token from an Asp.net Web Api 2.2 service. I have followed this article to setup an authorization server in Web Api service. I'm using RestSharp in the client.
client code:
var client = new RestClient(http://localhost:58030);
client.Timeout = 30000;
var request = new RestRequest(@"/Oauth/Token", Method.POST);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddHeader("grant_type", "password");
request.AddHeader("username", "[email protected]");
request.AddHeader("password", "Admin@456");
IRestResponse response = client.Execute(request);
result = response.Content;
As a result I'm getting following error:
{
"error_description":"grant type not supported",
"error":"unsupported_grant_type"
}
You added grant_type
,username
and password
to the Header
of the http request , it should be in Body
part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With