0
我有Android客户端,试图使用Asp.Net WebApi2获取身份验证令牌。每次我提出请求时都会收到{error:unsupported_grant_type}。我的问题是,这可能与我的WebAPI项目中的CORS启用相关吗?应该(而不是如何)我使用从Android客户端使用WebApi的CORS
我有Android客户端,试图使用Asp.Net WebApi2获取身份验证令牌。每次我提出请求时都会收到{error:unsupported_grant_type}。我的问题是,这可能与我的WebAPI项目中的CORS启用相关吗?应该(而不是如何)我使用从Android客户端使用WebApi的CORS
与CORS无关。
你检查你的请求的ContentType的是application/x-www-form-urlencoded
在体内传递的数据为:
grant_type=password&username=bob&password=password123
我的ContentType,并已通过你和grant_type字符串描述的设置相同的设置,但我会把身体放入标题中。 PS:你能简单解释为什么CORS与这种情况无关吗? –
CORS适用于浏览器执行跨域请求。请阅读维基页面https://en.wikipedia.org/wiki/Cross-origin_resource_sharing –