带有基本身份验证和JSONP的angularJS$资源
我是angularJS的新手,我正在使用$resource访问RestAPI。在$resource中是否可以使用angularJS中的JSONP进行身份验证?是的,这是可能的 您应该将httpRequests的标题配置为包含带有基本身份验证和JSONP的angularJS$资源,angularjs,jsonp,Angularjs,Jsonp,我是angularJS的新手,我正在使用$resource访问RestAPI。在$resource中是否可以使用angularJS中的JSONP进行身份验证?是的,这是可能的 您应该将httpRequests的标题配置为包含with credentials一个 可以这样做: var myApp = angular.module('myApp', []); myApp.config(['$httpProvider', function($httpProvider) { // Defaul
with credentials
一个
可以这样做:
var myApp = angular.module('myApp', []);
myApp.config(['$httpProvider', function($httpProvider) {
// Default with credential to all methods
$httpProvider.defaults.withCredentials = true;
}]);
有关标头的详细信息,请参阅。如果您的身份验证需要标头,可以这样设置$http.defaults.headers.common['Authorization']=。。。