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。 –