8
尝试通过邮递员调用OWIN OAuth安全的Web Api来获取JWT时,出现“错误”:“ unsupported_grant_type”
我已关注本文以实现OAuth授权服务器。但是,当我使用邮递员获取令牌时,响应中出现错误: “错误”:“ unsupported_grant_type” 我读到某处需要使用来发布Postman中的数据Content-type:application/x-www-form-urlencoded。我已经在Postman中准备了所需的设置: 但是我的标题是这样的: 这是我的代码 public class CustomOAuthProvider : OAuthAuthorizationServerProvider { public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { context.Validated(); return Task.FromResult<object>(null); } public override Task MatchEndpoint(OAuthMatchEndpointContext context) { if (context.OwinContext.Request.Method == "OPTIONS" && context.IsTokenEndpoint) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Methods", new[] { "POST" }); context.OwinContext.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "accept", "authorization", "content-type" }); context.OwinContext.Response.StatusCode = 200; …