Skip to content

Add snippet for Auth Emulator + Google Credential #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions auth-next/emulator-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ function emulatorConnect() {
// [END auth_emulator_connect]
}

function emulatorGoogleCredential() {
// [START auth_emulator_google_credential]
const { getAuth, signInWithCredential, GoogleAuthProvider } = require("firebase/auth");

const auth = getAuth();
signInWithCredential(auth, GoogleAuthProvider.credential(
'{"sub": "abc123", "email": "[email protected]", "email_verified": true}'
));
// [END auth_emulator_google_credential]
}


11 changes: 10 additions & 1 deletion auth/emulator-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import "firebase/auth";

function emulatorConnect() {
// [START auth_emulator_connect]
var auth = firebase.auth();
const auth = firebase.auth();
auth.useEmulator("http://localhost:9099");
// [END auth_emulator_connect]
}

function emulatorGoogleCredential() {
// [START auth_emulator_google_credential]
const auth = firebase.auth();
auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(
'{"sub": "abc123", "email": "[email protected]", "email_verified": true}'
));
// [END auth_emulator_google_credential]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This snippet file was generated by processing the source file:
// ./auth-next/emulator-suite.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.

// [START auth_emulator_google_credential_modular]
import { getAuth, signInWithCredential, GoogleAuthProvider } from "firebase/auth";

const auth = getAuth();
signInWithCredential(auth, GoogleAuthProvider.credential(
'{"sub": "abc123", "email": "[email protected]", "email_verified": true}'
));
// [END auth_emulator_google_credential_modular]