【问题标题】:Google Chrome Extension with OAuth带有 OAuth 的 Google Chrome 扩展程序
【发布时间】:2013-06-18 21:32:06
【问题描述】:

我正在尝试将 OAuth 与我的 chrome 扩展程序集成。我正在关注谷歌的教程:https://developer.chrome.com/extensions/tut_oauth.html

我从 background.js(由我定义并由 background.html 加载)创建 ExOauth。

var oauth = ChromeExOAuth.initBackgroundPage({
    'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
    'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
    'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
    'consumer_key': 'anonymous',
    'consumer_secret': 'anonymous',
    'scope': 'https://docs.google.com/feeds/',
    'app_name': Test app'
  });

 oauth.authorize(onAuthorized);

这是 OnAuthorized 方法:

onAuthorized = function () {
    // Start my application logic.
};

我在这里遗漏了什么吗?当我加载扩展程序时,它会打开几个“重定向....”选项卡。

【问题讨论】:

  • 我仍然有这个问题,它不断打开新标签。你是怎么解决的?

标签: oauth google-chrome-extension


【解决方案1】:

本教程似乎缺少一个文件。如果你打开chrome_ex_oauth.html,你会看到它尝试加载3个js文件:

<script type="text/javascript" src="chrome_ex_oauthsimple.js"></script>
<script type="text/javascript" src="chrome_ex_oauth.js"></script>
<script type="text/javascript" src="onload.js"></script>

未提供onload.js 文件。 OAuth contacts example提供了这样一个文件,内容如下:

window.onload = function() {
     ChromeExOAuth.initCallbackPage();
}

添加此文件后,它似乎工作正常。

【讨论】:

  • 我做了这个文件,但它仍然不断打开数百个标签。我该如何解决这个问题?
  • @avi 我在 Chrome OAuth ext 打开数百个标签时遇到了这个问题。你有没有弄清楚问题是什么?
【解决方案2】:

我知道这个问题有点老,但我遇到了同样的问题。

我犯了一个错误,我想验证两个 oauth 端点并两次调用 ChromeExOAuth.initBackgroundPage({}) 显然这是错误的,因为我不想两次初始化我的背景页面。

也许使用 ..._oauthsimple.js 可以解决这个问题

【讨论】:

    猜你喜欢
    • 2014-10-02
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 2013-11-02
    • 2016-05-13
    • 2015-08-30
    • 1970-01-01
    • 2012-06-19
    相关资源
    最近更新 更多