Google OAuth implementation with JQuery, is it possible?
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.开发者_C百科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.
I tried to do similar things in an extension, and got it working after adding the following permissions into manifest.json.
"permissions": [
"tabs",
"https://www.google.com/"
],
The original thread was here: Chrome Extension oAuth Request Redirect Page Not Loading
精彩评论