当我在 asp.net webapi 2 中设置 OAuth 授权服务器时,如何将令牌端点设置为接受 json 而不是表单编码的帖子?
使用示例http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api
我试图发送应用程序/json
{
"grant_type":"password",
"username":"Alice",
"password":"password123"
}
我收到响应 400 Bad Request
{
"error" : "unsupported_grant_type"
}
其中作为 application/x-www-form-urlencoded 的内容类型和grant_type=password&username=Alice&password=password123
预期的作品主体。
200 好
{
"access_token" : "08cQ33ZG728AqBcj1PBsRSs4iBPc02lLCZfpaRRWLx2mH_wpQzMwGDKS7r7VgJiKUjUFaq6Xv0uguINoiB_evVbVOtvyWaqAYvc0HRjlgrbj12uQqFbUB7bgH-jiyfhumkwuTSTVHfKUhBjCuD_pbyxEbu2K5WSJpUVge_SGxnb-htm4ZNf1qKDmpEnP9IpZVeJa-KnV0m0gEmP04slMW_JrO390LzCNvXZwVk1yMNuvDakk8tWX7Y6WkFoh7vtW6xfhw3QMbmnvS6px70yMWcTksRNG2bdmi4SenhuRTJx8IsCMnz-4Co7KiCNJGF7KLeU4WzE-LSqXv3mQ30CIQ7faXoMn53p83wZ1NoXYyhsNrQD4POUns_Isb_Pax5gvpZEdyo8zr1r7wb0dS7UXvJb0PWzLHc57Pg3u0kmcizQ",
"token_type" : "bearer",
"expires_in" : 1209599,
"userName" : "Alice",
".issued" : "Wed, 30 Oct 2013 15:16:33 GMT",
".expires" : "Wed, 13 Nov 2013 15:16:33 GMT"
}