0
我正在使用AppGyver和AngularJS構建移動應用程序。請求OAUTH令牌時出現重大錯誤
Restangular.all("token")
.post({
grant_type: "password",
username:username,
password:password
});
我RESTangular是建立這樣:
appServerModule.config(function(RestangularProvider) {
RestangularProvider.setBaseUrl('http://192.168.1.58/AppServer/api');
RestangularProvider.setErrorInterceptor(function(response) {
steroids.logger.log("RestangularProvider error:" + JSON.stringify(response));
});
});
當我執行POST
在登錄頁面,我用這個做一個POST請求我的Web API服務器請求我在記錄器中獲得以下輸出:
"RestangularProvider error:{"data":"","status":0,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"},"url":"http://192.168.1.58/AppServer/api/token","data":{"grant_type":"password","username":"AppServer","password":"AppServer"}},"statusText":""}"
正如您所看到的,錯誤消息不包含任何有用的信息,所以我不知道發生了什麼問題。 我可以在瀏覽器中使用Postman執行POST,並且Web API設置爲允許CORS。
我在這裏錯過了什麼? 如何獲得有關幕後發生的更多信息?
請注意,我在移動設備上執行此操作。
額外的信息: GET請求提供這種預期Restangular錯誤:
"RestangularProvider error:{"data":{"Message":"Authorization has been denied for this request."},"status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"headers":{"Accept":"application/json, text/plain, */*"},"url":"http://192.168.1.58/AppServer/api/chapters"},"statusText":"Unauthorized"}"