python - AllowAccess issue even if my server has `Access-Control-Allow-Origin:*` -


i'm trying access box.com api, xhr perform browser give me follow access-control-allow-origin issue:

[error] xmlhttprequest cannot load https://www.box.com/api/oauth2/token. origin http://localhost:8888 not allowed access-control-allow-origin. (localhost, line 0) 

i use easy python server found @ this gist

it has (at line 44) line of code self.send_header("access-control-allow-origin", "*") , think auld work correctly... right?

this code generate xmlhttprequest:

this.getaccesstoken = function(code) {   var parameters = 'grant_type=authorization_code' +     '&code=' + code +     '&client_id=' + box.client_id +     '&client_secret=' + box.client_secret;    var xhr = new xmlhttprequest();   xhr.open('post', 'https://www.box.com/api/oauth2/token');   xhr.setrequestheader("content-type", "application/x-www-form-urlencoded");   xhr.setrequestheader("content-length", parameters.length);   xhr.responsetype = 'json';    xhr.onreadystatechange = function() {     if (xhr.readystate == 4 && xhr.status == 200) {       alert(xhr.response);     }   }    xhr.send(parameters); } 

before can use xhr/cors request, have submit box support application , why need exception. not allow * cors "access control allow origin" entry. have tell box url you're going pitch stuff from.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -