Twitter :Application-only authentication error Origin null is not allowed by Access-Control-Allow-Origin


i am trying to send a application only authentication request to twitter to get the access_token .i write a javascript code

function getTwitterAuthorizeTokens() { return {oauth_token: "abcdefg", oauth_token_secret: "asdfasdfasfdasdf"}; }

// Get the consumer key and secret
function getTwitterConsumerTokens() {
    return {key: "xxxxxxxxxxxxxxxxx", secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"};
var s = encodeURIComponent(getTwitterConsumerTokens().key,'RFC 1738'); s += ':'+encodeURIComponent(getTwitterConsumerTokens().secret,'RFC 1738'); $( document ).ready(function(){ $.ajax({ type:"POST", beforeSend: function (request) { request.setRequestHeader("Authorization", "Basic "+s); request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); }, url: "", data: "grant_type=client_credentials", processData: false, success: function(msg) { alert("successfull"); } });

when this script is loaded .it is giving me error in console

OPTIONS 405 (Method Not Allowed) sinon-server-1.7.1.js:573
apply sinon-server-1.7.1.js:573
fakeXhr.(anonymous function) sinon-server-1.7.1.js:592
send jquery.min.js:4
f.extend.ajax jquery.min.js:4
(anonymous function) index.html:143
e.resolveWith jquery.min.js:2
e.extend.ready jquery.min.js:2
c.addEventListener.C jquery.min.js:2
XMLHttpRequest cannot load Origin null is not allowed by Access-Control-Allow-Origin. index.html:1
how to resolve this error please guideline. i am following this link


Same here, someone please help.


Same here


No answers yet ? Anyone… ?