I'm trying for a purely client side implementation of OAuth for Google APIs using jQuery. i'm making use of oauth.js and sha1.js libraries.
url = "https://www.google.com/accounts/OAuthGetRequestToken";
var accessor = { consumerSecret: 'abc' };
var parameter = {
oauth_consumer_key:'www.oauthorization.appspot.com',
oauth_signature_method:'HMAC-SHA1',
scope:'http://www.google.com/calendar/feeds/private/default/full',
oauth_timestamp:010111,oauth_nonce:abc,
oauth_signature:qbc,
oauth_callback:'http://abc.appspot.com/'
}
OAuth.setTimestampAndNonce(message);
OAuth.SignatureMethod.sign(message, accessor);
$.ajax({
url: url,
type: "POST",
beforeSend: function( xhr ) {
xhr.overrideMimeType( 'application/x-www-form-urlencoded' );
xhr.setRequestHeader('Authorization', 'OAuth');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
},
data: parameter
});
On triggering the above AJAX call i get a 405 method not allowed error on firefox and Origin null is not allowed by Access-Control-Allow-Origin. in chrome.
Please help in solving those errors or point me to some working examples of jQuery OAuth implementations for Google.