diff --git a/auth-next/emulator-suite.js b/auth-next/emulator-suite.js index 84d57ed0..66507de3 100644 --- a/auth-next/emulator-suite.js +++ b/auth-next/emulator-suite.js @@ -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": "foo@example.com", "email_verified": true}' + )); + // [END auth_emulator_google_credential] +} + + diff --git a/auth/emulator-suite.js b/auth/emulator-suite.js index 044795a7..b14a72db 100644 --- a/auth/emulator-suite.js +++ b/auth/emulator-suite.js @@ -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": "foo@example.com", "email_verified": true}' + )); + // [END auth_emulator_google_credential] +} diff --git a/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js b/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js new file mode 100644 index 00000000..d3683bb0 --- /dev/null +++ b/snippets/auth-next/emulator-suite/auth_emulator_google_credential.js @@ -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": "foo@example.com", "email_verified": true}' +)); +// [END auth_emulator_google_credential_modular] \ No newline at end of file