Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created September 28, 2023 18:10
Show Gist options
  • Save patrickkettner/50291d324bd5decffe92ab34cfd85606 to your computer and use it in GitHub Desktop.
Save patrickkettner/50291d324bd5decffe92ab34cfd85606 to your computer and use it in GitHub Desktop.
import { GoogleAuthProvider, initializeAuth } from "firebase/auth";
chrome.identity.getAuthToken({ 'interactive': true }, async (token) => {
const credential = GoogleAuthProvider.credential(null, token);
try {
const app = initializeApp({/** Your app config */});
const auth = initializeAuth(app, {popupRedirectResolver: undefined});
const {user} = await auth.signInWithCredential(credential)
console.log(`the user object is here! - ${user}`)
} catch (e) {
console.error(error);
}
});
{
"name": "firebase-auth-remote-code-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c rollup.config.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"firebase": "9.18.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.1",
"rollup": "^3.29.3"
}
}
import { nodeResolve } from '@rollup/plugin-node-resolve';
export default {
input: './index.mjs',
output: {
file: './bundle.js',
format: 'iife'
},
plugins: [nodeResolve()]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment