gpt4 book ai didi

oauth - 带有 OAuth 的 Google Chrome 扩展

转载 作者:行者123 更新时间:2023-12-04 12:32:58 25 4
gpt4 key购买 nike

我正在尝试将 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.
};

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

最佳答案

该教程似乎缺少一个文件。如果您打开 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();
}

添加此文件后,它似乎工作得很好。

关于oauth - 带有 OAuth 的 Google Chrome 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17240533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com