小编Tec*_*ech的帖子

Firebase 3rd-party AuthProvider (Google/Facebook/etc) 使用 chrome 扩展清单 v3 登录

Chrome 扩展的 Manifest 版本 3 最近让我苦恼不已。到目前为止我已经能够浏览它了,但是这个确实难倒了我。我正在尝试对 Chrome 扩展程序使用 Firebase 身份验证,特别是与 Google 和 Facebook 等第三方身份验证提供商一起使用。我已经为“使用 Google 登录”设置了 Firebase 配置,并在 Chrome 扩展程序的选项页面中创建了登录部分,并设置了 Firebase SDK。

现在,使用身份验证提供程序时有两个登录选项,signInWithRedirect以及signInWithPopup。我已经尝试过这两种方法,但由于不同的原因都失败了。signInWithRedirect似乎完全是一个死胡同,因为它重定向到身份验证提供程序,并且当它尝试重定向回 chrome-extension://.../options.html 页面时,它只是重定向到“about:blank#blocked” 。

当尝试使用时signInWithPopup,我反而得到

Refused to load the script 'https://apis.google.com/js/api.js?onload=__iframefcb776751' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
Run Code Online (Sandbox Code Playgroud)

在 v2 中,您只需添加https://apis.google.com到清单中的 content_security_policy 即可。但在 v3 中,文档说

“此外,MV3 不允许对 MV2 中允许的 extension_pages …

authentication google-chrome-extension firebase

15
推荐指数
1
解决办法
1908
查看次数