1
我试图从ArcGIS Online服务使用Javascript获取令牌。但是,它总是返回一个错误,指示未指定client_id。JSON始终返回“client_id未指定”
我在这里做的一切吗?
<script type="text/javascript">
var MyJSONText = '{"client_id":"<<MY_CLIENT_ID>>","client_secret":"<<MY_CLIENT_SECRET>>","grant_type":"client_credentials","expiration":"1440","f":"json"}';
var MyJSON = JSON.parse(MyJSONText);
xhr = new XMLHttpRequest();
xhr.open("POST", "https://www.arcgis.com/sharing/rest/oauth2/token/");
xhr.send(MyJSON);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
alert(xhr.responseText);
}
}
</script>
编辑 - 全错误是:
{"error":{"code":400,"error":"invalid_request","error_description":"client_id not specified","message":"client_id not specified","details":[]}}
在console.log中的预检响应中,带回了'请求标头字段'Content-type不被允许通过Access-Control-Allow-Headers。 – user25730
对不起,仍然回来'client_id未指定'错误。 – user25730
是的,仍然有同样的错误。无论如何感谢 - 将它标记为答案。看起来我必须重新评估我使用的方法,并更多地了解如何使用node.js – user25730