1
你好,我是用箱API来整合他们给刚刚卷曲获得访问令牌 这是遵循发布采购信息
curl https://www.box.com/api/oauth2/token \
-d 'grant_type=authorization_code&code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}' \
-X POST
我想使用jQuery Ajax请求我一定要得到的访问令牌累了我这样的代码如下:
var data2= '{"grant_type":"authorization_code", "client_id":"READACTED" ,"client_secret":"Redacted" ,"code" :"'+code+'"}';
var data1 = JSON.parse(data2);
$.ajax({
type: 'POST',
url: "https://www.box.com/api/oauth2/token",
data: data1,
success: function(json) {
console.log(e);
alert("success"+json);
},
error: function(e) {
console.log(e)
alert("Failure"+ JSON.stringify(e));
}
});
我现在面临的问题与此请求,因为它给了我在浏览器控制台错误:
XMLHttpRequest cannot load https://www.box.com/api/oauth2/token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
请告诉我我错在哪里,它和Postman客户端正常工作。
你想做什么?你有什么尝试? –
@RocketHazmat请现在检查我已经提到更多详细信息 –
您被[相同来源政策]阻止(http://en.wikipedia.org/wiki/Same-origin_policy)。您无法直接从JavaScript访问box.com API。 –