【问题标题】:Google OAuth implementation with JQuery, is it possible?使用 JQuery 实现 Google OAuth,这可能吗?
【发布时间】:2011-09-30 10:48:27
【问题描述】:

我正在尝试使用 jQuery 为 Google API 的 OAuth 的纯客户端实现。 我正在使用oauth.jssha1.js 库。

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
});

在触发上述 AJAX 调用时,我在 firefox 上收到 405 method not allowed 错误,并且 Access-Control-Allow-Origin 不允许使用 Origin null。 在 chrome 中.

请帮助解决这些错误或向我指出一些适用于 Google 的 jQuery OAuth 实现的工作示例。

【问题讨论】:

标签: jquery oauth google-api


【解决方案1】:

我尝试在扩展中做类似的事情,并在将以下权限添加到 manifest.json 后使其工作。

"permissions": [
    "tabs",
    "https://www.google.com/"
  ],

原帖在这里:Chrome Extension oAuth Request Redirect Page Not Loading

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 2021-10-24
    相关资源
    最近更新 更多