【问题标题】:Access-Control-Allow-Origin error when making a HTTP request发出 HTTP 请求时出现 Access-Control-Allow-Origin 错误
【发布时间】:2013-04-26 08:43:49
【问题描述】:

您好,我正在通过 OAuth 2.0 对用户进行身份验证,并且在发出以下 POST 请求时遇到 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.):

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 并添加了 callback=?到网址,但我尝试过的没有任何效果。

【问题讨论】:

    标签: javascript jquery html oauth-2.0 box-api


    【解决方案1】:

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

    Box API 在 逐个应用程序。如果您正在构建需要 CORS 的应用程序, 请联系我们并提供您的用例说明。

    【讨论】:

      【解决方案2】:

      另一种方法是使用YQL,正如他们的开发人员在常见问题解答中所描述的那样。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-01
        • 2014-02-01
        • 2017-01-28
        • 2017-12-30
        • 2018-08-26
        • 2018-04-16
        • 2017-06-15
        • 1970-01-01
        相关资源
        最近更新 更多