Firebase SDK 9 + Google Sign In + Chrome Extension Manifest Version 3 + Webpack

Overview

Firebase SDK 9 + Google Sign In + Chrome Extension Manifest Version 3 + Webpack

Demo

Find this Chrome Extension Setup and working demo here or on Youtube!

Boilerplate Code Brief

The Chrome Extension with MV3 version shows example of authentication of Firebase SDK9 with Google Sign In enable. This boilerplate uses Webpack to speed up the process of writing modular Javascript code, loading HTML and CSS easily, and automatic reload the browser based on changes.

Why?

As per the Chrome Extension Timeline, all extensions supporting Manifest Version v2 will sunset in Jan 2023, and for new extensions, it has now become a requirement to move to Manifest Version V3.

Google Chrome Extension Manifest v3's most significant security change is that remotely hosted code, such as Javascript, is now not allowed. If your extension codebase is not bundled and structured in a modular fashion, this can lead to problems. A beginner like me will definitely have a hard time building a setup like that without any guideline.

When I built my Chrome Extension, I had limited experience with webpack, and I believe that new beginners may have the same issue, which is why I decided to compile this resource.

Firebase

Including Firebase libraries is an example.

There are lots of changes already from moving MV2 to MV3 version for chrome extension. At the same time, firebase latest version suggests using SDK9 which needs module bundler support. I could not find guideline and hit few issues , that I will list down below going over the documentation. As of today 31, Jan 2022, the documentation support for including firebase SDK9 in Chrome Extension is still confusing.

Issues:

With this repo, I have made it work for my use case to enable Google Sign In and ( you can extend the logic for other sign in methods) by combining the resources /code snippets and hopefully it will help someone, moving to Chrome Extension MV3 version this year.

Referrences:

Structure

I am assuming you have followed the steps to add Firebase Authentication to your web application and have access to Firebase console.

I am assuming you have taken look for introduction at the Chrome Extension docs and Webpack docs.

Also, if you are beginner, I am assuming you probably would have worked on the Getting Started Guide for extension. If not, I would give a quick look at it as well.

This repo bundles the code explained in the Getting Started Guide with Webpack.

Initial Setup

Make sure you have latest Node.js installed.

My current version:

(base) ➜  ✗ node --version
v16.13.1
(base) ➜  ✗ npm --version
8.1.2

For the initial setup, below webpack bundles were installed:

npm install --save-dev webpack webpack-cli html-webpack-plugin clean-webpack-plugin copy-webpack-plugin

For the Firebase setup, below webpack bundles were installed:

npm install firebase firebaseui --save

Configuration

webpack.development.js

For Development Purposes, you can configure this script and run the command npm run build to reflect changes.

webpack.production.js

For production release, you can configure this script and run the command npm run release to reflect changes.

webpack.common.js

This script contains all the common bundler config common between development and production scripts above.

src

All your extension's development code must be placed in src folder, including the extension manifest.

The boilerplate is already prepared to have a popup, a options page and a background page. You can easily customize this.

Includes:

  • background.js
  • content.js
  • popup (js + html + css)
  • options (js + html)

src/manifest.json

  • This is the entry point for your extension.
  • Added "identity" to permission to support authenticate operations.
  • Fill the OAuth details in the manifest, which are custom to your project/app.
.apps.googleusercontent.com", "scopes": [ "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" ] }, "key": "-----BEGIN PUBLIC KEY-----\n \n-----END PUBLIC KEY-----" ">
  "oauth2": {
    "client_id": "
    
     .apps.googleusercontent.com",
    "scopes": [
      "https://www.googleapis.com/auth/userinfo.email",
      "https://www.googleapis.com/auth/userinfo.profile"
    ]
  },
  "key": "-----BEGIN PUBLIC KEY-----\n
     
      \n-----END PUBLIC KEY-----" 

     
    

src/popup/firebase_config.js

This is the firebase config script, and you can referrence this in any other javascript by import statement.

import { firebaseApp } from './firebase_config'

Fill the details for your config, which you get after registering the Firebase app

", authDomain: " ", projectId: " ", storageBucket: " ", messagingSenderId: " ", appId: " ", measurementId: " " };">
// config after registering firebase App 
const config = {
    apiKey: "
          
           ",
    authDomain: "
           
            ",
    projectId: "
            
             ",
    storageBucket: "
             
              ",
    messagingSenderId: "
              
               ", appId: "
               
                ", measurementId: "
                
                 " }; 
                
               
              
             
            
           
          

To provide Google Sign In, the code below used authorizes Firebase (GoogleAuthProvider) with the OAuth Access Token, which will build Firebase credential with the Google ID token.

Code Snippet:

{">
            const credential = GoogleAuthProvider.credential(null, token);
            signInWithCredential(auth, credential).then((result) => {
                console.log("Success!!!")
            }).catch((error) => {

How to use it

  1. Clone the repo
  2. Fill all the details for Firebase App (Secrets) by replacing strings
  3. Find these details as explained above
  4. Run command npm install to install all node-modules / dependencies
  5. Run command npm run build
  6. This will build the dist folder
  7. Load your extension on Chrome following:
    1. Access chrome://extensions/
    2. Check Developer mode
    3. Click on Load unpacked extension
    4. Select the dist folder

Note: gitignore will help ignore the node_modules and dist folder to be pushed to the github


Blog | Rasika Warade

You might also like...

Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's `move-ts`.

Movehat Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's move-ts. Movehat aspires to b

Sep 30, 2022

⚡Chrome extension allows you to create lists of Google and Github dork to open multiple tabs with one click, import "scope/out of scope" from #HackerOne #Bugcrowd #Intigriti ...

⚡Chrome extension allows you to create lists of Google and Github dork to open multiple tabs with one click, import

FastDork v0.1 This chrome extension allows you to create lists of Google and Github dork to open multiple tabs with one click, import "scope/out of sc

Dec 31, 2022

🚀 A web extension starter built with React, Typescript, and Tailwind CSS. Build once, and run on multiple browsers: Google Chrome, Mozilla Firefox, Microsoft Edge, Brave, and Opera..

🚀 A web extension starter built with React, Typescript, and Tailwind CSS. Build once, and run on multiple browsers: Google Chrome, Mozilla Firefox, Microsoft Edge, Brave, and Opera..

Web Extension Starter A web extension starter, built with React, Typescript, and Tailwind CSS. Build once, and run on multiple browsers: Google Chrome

Dec 28, 2022

A password manager extension for Google Chrome.

Password Manager for Chrome NOTE: This project is a prove of concept / sample application for a chromium based web-browser and originated form the you

Dec 12, 2022

This is a Google Chrome Extension which blocks social media sites.

This is a Google Chrome Extension which blocks social media sites.

Social Media Blocks (1.0.3) This is a Google Chrome Extension which blocks social media sites like Twitter: Facebook, Instagram, LinkedIn, WhatsApp, R

Dec 15, 2022

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early

RWP stands for Roblox web panel, it's a code snippet that you can run via developer console or the provided Google Chrome extension to try out early Roblox site features before they're officially out without any programming experience.

Nov 28, 2022

A small web app that tries to imitate the desktop web version of amazon site, you can add items to the basket, delete them, and have your user authentication feature thanks to Firebase.

A small web app that tries to imitate the desktop web version of amazon site, you can add items to the basket, delete them, and have your user authentication feature thanks to Firebase.

Features Here's the feature's included in this project 👨‍👩‍👧‍👦 Login Page 📦 Products Page 🛒 Cart and Checkout Page 📝 Sign up function with Goog

Aug 22, 2022

A google firebase based task-manager made in typescript

By Harshiyt Kumar This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yar

Aug 7, 2022

blog with angular made in sass and firebase auth with google, facebook and github also you can copy to clipboard

blog with angular made in sass and firebase auth with google, facebook and github also you can copy to clipboard

BlogAngular This project was generated with Angular CLI version 14.1.2. Development server Run ng serve for a dev server. Navigate to http://localhost

Oct 2, 2022
Comments
  • Where to find oauth2 key

    Where to find oauth2 key

    Thank you very much for this repo, it's been super helpful. I have one question: where did you get the oauth2 key that you added to the manifest file? I checked all the docs and I can't seem to find this anywhere. Thanks in advance!

    opened by jedfonner 2
  • List for choosing google account is not visible

    List for choosing google account is not visible

    I had tried cloning your repo and filling in all the necessary details as required.

    • I then tried signing in, but the problem is that I am not asked to choose my google account My default chrome account is being chosen to login. (Basically, there should have been a list of google accounts to choose from, which is missing)

    What could be the problem? Can you please look into this issue?

    Do check this video, I have recorded the problem that I am facing: https://www.loom.com/share/14e5236831f14223a4384504291aca20

    opened by master30112001 0
Owner
Rasika Warade
Developer @Shopify
Rasika Warade
Chrome Extension Boilerplate with SolidJS + Vite + TypeScript + Manifest V3 + HMR

mv3-solid-chrome-extension-template chrome-extension development template with firebase Support Chrome Extension Manifest V3 SolidJS Typescript HMR Fi

munron 6 Dec 13, 2022
Login of app to remind to drink water, using Firebase tools like Firebase Auth and Firebase Firestore

Water Reminder Login App Menu Contents Motivation Final Images How to download the project and run it? Technologies utilized Dev ?? Motivation This ap

Ilda Neta 10 Aug 22, 2022
A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email.

Strapi PasswordLess Plugin A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email. A pl

Andrey Kucherenko 51 Dec 12, 2022
A comprehensive user sign-up/sign-in system

Nodejs Login System You want a comprehensive user sign-up/sign-in system I strongly suggest you take a look at this repo. The System Includes Welcome

Furkan Gulsen 8 Aug 1, 2022
⏱ A Google Chrome extension for keeping track of who is talking during Google Meets

Am I Talking A Lot? ⏱ A Google Chrome extension for keeping track of who is talking during Google Meets Features Tracks talking time for each particip

Sean McPherson 8 Oct 5, 2022
Google Chrome release and version info as JSON (self updating)

chrome-versions Self updating repository to store Google Chrome release and version info as JSON. Windows macOS Linux Android TL;DR Use a CDN to fetch

berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ 9 Dec 15, 2022
Google-Drive-Directory-Index | Combining the power of Cloudflare Workers and Google Drive API will allow you to index your Google Drive files on the browser.

?? Google-Drive-Directory-Index Combining the power of Cloudflare Workers and Google Drive will allow you to index your Google Drive files on the brow

Aicirou 127 Jan 2, 2023
Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or enter your email address and more.

Demodal Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or en

Elbert Alias 225 Jan 4, 2023
esbuild plugin to generate mix-manifest.json file compatible with Laravel Mix.

esbuild-mix-manifest-plugin An esbuild plugin to generate a mix-manifest.json compatible with Laravel Mix. Installation You can install the plugin via

Stefan Zweifel 6 Dec 25, 2022
The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling rapid development of iofod extensions through the SDK.

iofod-sdk English | 简体中文 The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling

iofod, Inc. 47 Oct 17, 2022