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 –