【发布时间】:2015-03-03 19:04:35
【问题描述】:
我是 Web Api 2 的新手。我正在尝试构建一个项目来探索令牌授权。我在 VS 2013 中创建了一个新项目并选择了 WebApi2 模板并使用 Fiddler 来模拟 http 请求。我没有更改模板中的任何内容,只是按原样运行它并尝试与 Fiddler 一起玩。我通过向 /api/account/register 发出请求成功地创建了一个用户,但我无法通过向 /Token 端点发出 POST 请求来登录。请求是:
http://localhost:YYYY/token?grant_type=password&password=admin123456&username=admin
(我也尝试将参数作为请求正文中的 json 对象传递)。
我回来了:
{"error":"unsupported_grant_type"}
从ASP.NET WEB API 2 OWIN Authentication unsuported grant_Type 等其他帖子中,我了解到我需要为 web api 和令牌端点启用 CORS,但这对我不起作用。
【问题讨论】:
标签: asp.net authentication token asp.net-web-api2 identity