【发布时间】:2014-11-05 19:34:07
【问题描述】:
WEBAPI 为认证请求提供端点:http:\...\token
身份验证请求应使用方法“POST”和 Body like 发送
"grant_type=password&username=name&password=mypassword"
此 WebAPI 由使用 AngularJS 编写的前端使用。 有时在发送带有有效正文的“POST”请求之前,会发送一个没有正文的“OPTIONS”请求。 结果WebAPI返回以下错误:
Status: 400
{"error":"unsupported_grant_type"}
有没有可以在服务器端实现的解决方案? (在 WebAPI 中)
HTTP 请求方法:选项
Request Header:
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,de;q=0.6,ru;q=0.4,uk;q=0.2
Access-Control-Request-Headers:accept, authorization, content-type
Access-Control-Request-Method:POST
Cache-Control:no-cache
Host:...
Origin:...
Pragma:no-cache
Proxy-Connection:keep-alive
Referer:...
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Response Header:
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 34
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Date: Thu, 11 Sep 2014 18:05:09 GMT
【问题讨论】:
标签: authentication oauth options