我正在运行一个基于 AngularJS 构建的测试站点,并且在尝试让 Forge OAuth 运行时遇到问题。这是我试图提出的要求......
$http({
method: 'POST',
url: 'https://developer.api.autodesk.com/authentication/v1/authenticate',
data: 'client_id=' + token.clientId + '&client_secret=' + token.secret + '&grant_type:client_credentials&scope=data:read',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
withCredentials: false
}).then(function (r) {
authToken = r.access_token;
toastr.success('success');
}, function (e) {
toastr.error('fail');
});
它出错了:
XMLHttpRequest cannot load https://developer.api.autodesk.com/authentication/v1/authenticate. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 500.
我知道这是一个与 CORS 相关的问题,我不是这方面的专家。这不能使用 $http.post() 吗?如果没有,我应该如何使用 Angular 进行身份验证?