【发布时间】:2016-03-10 19:22:13
【问题描述】:
我正在尝试在我的 AngularJS 应用程序中连接到 FreeNAS (http://api.freenas.org/authentication.html) 的 REST API。 API 使用用户名和密码的基本身份验证。
在python中这是一件非常简单的事情,因为只有一行代码:
requests.get('http://freenas.mydomain/api/v1.0/account/bsdusers/',auth=('root', 'freenas'))
我试图为 AngularJS 找到一些东西,但只是因为令人痛苦的代码而跌跌撞撞,例如How do I get basic auth working in angularjs?
有没有类似的东西:
$http({
method: 'GET',
url: 'http://freenas.mydomain/api/v1.0/account/bsdusers/',
auth: ['username':'root', 'password':'pw']
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
【问题讨论】:
标签: python angularjs api httprequest