2013-05-02 70 views
2

嗨我正在通過OAuth 2.0驗證用戶的過程中,並且在製作時出現Access-Control-Allow-Origin錯誤(XMLHttpRequest cannot load https://www.box.com/api/oauth2/token. Origin http://localhost is not allowed by Access-Control-Allow-Origin.)以下POST請求:進行HTTP請求時訪問控制 - 允許 - 來源錯誤

var xhr=new XMLHttpRequest(); 
xhr.open('POST',path,true); 
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
xhr.onload = function() { 
    var text = xhr.responseText; 
    alert('Response from request to ' + path + ': ' + text); 
}; 
xhr.onerror = function() { 
    alert('Woops, there was an error making the request.'); 
}; 
xhr.send(params); 

任何幫助將不勝感激!我查看了CORS,JSONP,並添加了回調=?到的網址,但沒有我試過正在工作。

回答

1

http://developers.box.com/docs/

盒子API支持上的應用程式 逐個應用程序的基礎CORS。如果您正在構建需要CORS的應用程序,請致電 ,並與我們聯繫,並說明您的使用案例。

+0

ahhh我明白了,非常感謝你指出了這一點 – user2066880 2013-05-02 09:37:57

0

另一種方法是使用YQL,正如他們的開發人員在FAQ中所述。

相關問題