Help signin js/django


#1

Hi,
We’re trying to do a login with twitter on our website which uses angularjs/js for front end and django for back end. We can’t figure out how to get the request token. We think we have created a signature and are sending this:

var data = {“oauth_callback”:“http%3A%2F%2Flocalhost%2Fsign-in-with-twitter%2F”}
data=JSON.stringify(data)
xdr = new XMLHttpRequest();
try {
var temp = new XMLHttpRequest();
var xdr = temp;
xdr.onload = function() {
document.querySelector(’#resultats’).innerHTML = xdr.responseText;
}
xdr.open(method, url, true);
xdr.setRequestHeader(“Authorization”,headerAuth);
xdr.setRequestHeader(“Access-Control-Allow-Origin”,“https://api.twitter.com/”);
xdr.setRequestHeader(“Content-Type”, ‘application/json’);
xdr.send(data);
}
catch(e) {
alert(e);
}

with

headerAuth = OAuth oauth_callback=“http%253A%252F%252Flocalhost%252Fsign-in-with-twitter%252F”, oauth_consumer_key=“", oauth_nonce=“a0NVcHBUdTlINklaVWdaNTQ1M1czZjhjMFZQMTgxczA%3D”, oauth_signature="***************************************************************************”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1460473261.274”, oauth_version=“1.0”

We keep getting this error :XMLHttpRequest cannot load https://api.twitter.com/oauth/request_token. Response for preflight has invalid HTTP status code 400 or “origin is not allowed by Access-Control-Allow-Origin”.
Can you spot what our problem is or do you know a tutorial we could look follow?
Thanks!