以下のコードを使用して、Asp.net Web Api 2.2サービスからJWTアクセストークンを消費しています。私はthis articleに続いてWeb APIサービスで認証サーバーを設定しました。私はRestSharpをクライアントで使用しています。RestSharpを使用してJWTアクセストークンとユーザークレームを消費する方法
クライアントコード:私は次のエラーを取得していた結果
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", "[email protected]");
IRestResponse response = client.Execute(request);
result = response.Content;
:
私はこのエラーを取得していますし、私はこれをどのように修正することができますなぜ{
"error_description":"grant type not supported",
"error":"unsupported_grant_type"
}
- ?
- クライアントのユーザー名などのクレームにはどうすればアクセスできますか?
- また、Identity Modelを使用してサービスを使用するにはどうすればよいですか。