1

I'm trying to use a Dropbox API, specifically one that allows a team administrator to take action for the team member, but I keep getting an access-control-error.

Here's my code:

 $(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));
        }
    });
    
});

Here's the error I get: XMLHttpRequest cannot load https://api.dropbox.com/1/account/info. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Any ideas on what's going on here? Have tried using JSONP as a dataType and gotten a 401 authorization error. Not sure what I'm doing wrong here. Not using localhost or any domain, just have the HTML files on my desktop

5
  • Also here is the walkthrough of what Dropbox's API requires: dropbox.com/developers/business#member-file-access Commented Jun 24, 2015 at 23:06
  • Are you sure that API is supposed to work client-side? Commented Jun 24, 2015 at 23:10
  • At present, I'm working two APIs into my entire script. The first API does work client-side (it's a Team Member Listing API) It's when I start trying to do team-member actions that I find an issue. Find it odd that one works but the other doesn't Commented Jun 24, 2015 at 23:41
  • [Cross-linking for reference: dropboxforum.com/hc/communities/public/questions/… ]
    – Greg
    Commented Jun 24, 2015 at 23:42
  • This should be fixed now.
    – Greg
    Commented Jul 16, 2015 at 21:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.