gpt4 book ai didi

javascript - 带有 OAuth2 的 Chrome 扩展

转载 作者:行者123 更新时间:2023-11-29 19:16:09 25 4
gpt4 key购买 nike

我正在尝试创建一个 Chrome 扩展程序,它将一些数据保存到用户的 Google Drive。我认为 OAuth 是最好的解决方法。所以我在 manifest.json 中执行以下操作:

"oauth2": {
"client_id": "<my_client_id>",
"scopes": ["https://www.googleapis.com/auth/drive"]
}

之后,我想在我的 background.js 中使用 Google API 进行身份验证,使用 gapi.auth.authorize 等。但是即使我包含 https://apis.google.com/js/client.js 在manifest的后台脚本中,还是找不到。我究竟做错了什么?有没有更好的方式来使用 OAuth?

最佳答案

What am I doing wrong?

This基本上是你的问题。您正在尝试包含默认 CSP 禁止的远程脚本。这个可以放宽;见the question了解更多详情。

Is there a better way to use OAuth?

是的,chrome.identity API .你可以看看sample app由谷歌提供。

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

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