我正尝试连接到家中的家庭自动化服务器上的RESTFul API(因此不需要大规模安全性)。当我尝试使用没有凭据连接,我得到:Angular Digest Authentication
[Error] XMLHttpRequest cannot load http://localhost:8176/devices/. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
文档说:
靛蓝使用 “消化authentificaction”(没有基本也不令牌)
卷曲-X PUT - -digest -u {username}:{password} -d value = {value} http:// {IPAddress}:8176/variables/{VariableToChange}
curl -X PUT --digest -u admin:p @ ssw0rd -d value = true http:// {IPAddress}:8176/variables/Var1
要获得设备的列表,我可以用这3个之一:
http://127.0.0.1:8176/devices/
http://127.0.0.1:8176/devices.xml/
http://127.0.0.1:8176/devices.txt/
我就如何通过信条全盘损失。这里是我的代码到目前为止:
function DeviceController($scope, $http) {
$http.get("http://localhost:8176/devices/")
.then(function (results) {
//Success;
console.log("Succss: " + results.status);
$scope.devices = results.data;
}, function (results) {
//error
console.log("Error: " + results.data + "; "
+ results.status);
$scope.error = results.data;
})
};
任何人都可以指出我在正确的方向吗?
感谢
马克
我觉得家庭自动化服务器需要你能想到的尽可能多的安全性。 – icebreaker
@icebreaker - 不是在安全的本地网络上时 – mark1234