firebasegoogle-chromefirebase-authentication

Firebase authentication with popup in chrome extension


I'm trying to authenticate users via Firebase in a Chrome extension using Firebase Authentication. I want to use a popup to authenticate with Google and GitHub, but the popup isn't displaying. According to the documentation, I need to add the following URLs to the content_security_policy:

firebase snapshot

However, I've added these URLs and still encounter CSP (Content Security Policy) errors. Any suggestions on how to resolve this issue?

Manifest.json:

{
  "manifest_version": 3,
  "name": "Name",
  "version": "1.0.0",
  "description": "XXX",
  "author": "ISSS",
  "permissions": [
    "tabs",
    "activeTab",
    "offscreen"
  ],
  "host_permissions": [
    "https://*.googleapis.com/*",
    "https://*.firebaseapp.com/*",
    "https://*.firebase.google.com/*"
  ],
  "chrome_url_overrides": {
    "newtab": "index.html"
  },
  "action": {
    "default_icon": {
      "16": "icons/icon16.png",
      "32": "icons/icon32.png",
      "48": "icons/icon48.png",
      "128": "icons/icon128.png"
    }
  },
  "background": {
    "service_worker": "assets/background-DnhXaGSS.js",
    "type": "module"
  },
  "content_security_policy": {
    "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; connect-src 'self' https://*.firebaseapp.com https://*.googleapis.com wss://*.firebaseio.com https://identitytoolkit.googleapis.com https://accounts.google.com https://*.google.com"
  }
}

Solution

  • "content_security_policy": {
        "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; connect-src 'self' https://apis.google.com https://www.gstatic.com https://www.googleapis.com https://securetoken.googleapis.com"
      }