使用Dropbox API时Access-Control-Allow-Origin错误

时间:2015-06-24 23:04:24

标签: jquery dropbox

我正在尝试使用Dropbox API,特别是允许团队管理员为团队成员采取行动的API,但我不断收到访问控制错误。

这是我的代码:

 $(document.body).on('click', '.viewfolders', function() {
    var teamMember = $(this).closest('tr').attr('id');
    //JSONinputs = {"list": "true"};
    jQuery.ajax( {
        url: 'https://api.dropbox.com/1/account/info',
        type: 'GET',
        dataType: 'json',
        contentType: 'application/json',
        headers: {
            'X-Dropbox-Perform-As-Team-Member': + teamMember,
            "Authorization": "Bearer " + access_token
        },
        beforeSend : function( xhr ) {
            xhr.setRequestHeader( "Access-Control-Allow-Origin", "*");                
        },
        success: function(rootresult) {               
           alert('success');
        },
        error: function(response) {
            alert('error ' + JSON.stringify(response));
        }
    });
    
});

这是我得到的错误: XMLHttpRequest无法加载https://api.dropbox.com/1/account/info。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许原点'null'访问。

关于这里发生了什么的任何想法?尝试使用JSONP作为dataType并获得401授权错误。不知道我在这里做错了什么。不使用localhost或任何域,只需在我的桌面上放置HTML文件

0 个答案:

没有答案