When I setup an OAuth Authorization Server in asp.net webapi 2 how can I set the token endpoint to accept json rather then a form encoded post?
Using the sample http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api
I tried to send application/json
with
{
"grant_type":"password",
"username":"Alice",
"password":"password123"
}
I receive the response
400 Bad Request
{
"error" : "unsupported_grant_type"
}
where as a content type of application/x-www-form-urlencoded
and body of grant_type=password&username=Alice&password=password123
works as expected.
200 OK
{
"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"
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…