angular-http-auth

angularjs basic authentication headers

妖精的绣舞 提交于 2019-12-10 13:45:09
问题 I'm trying to connect to API and send authentication headers. I'm using Base64 as described here How do I get basic auth working in angularjs? function Cntrl($scope, $http, Base64) { $http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode('----myusername----' + ':' + '----mypass---'); $http({method: 'GET', url: 'https://.../Category.json'}). success(function(data, status, headers, config) { console.log('success'); }). error(function(data, status, headers, config) { alert