firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.85k stars 893 forks source link

linkWithRedirect does not work with auth emulator #4275

Open smousa opened 3 years ago

smousa commented 3 years ago

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

  1. Configure application to connect to Firebase Auth emulator

  2. Log into application using "google auth" credentials

  3. Unlink "google auth" credentials from the user by calling

    firebase.auth().currentUser.unlink('google.com')
  4. Relink "google auth" credentials to the user by calling

const googleProvider = new firebase.auth.GoogleAuthProvider()
firebase.auth().currentUser.linkWithRedirect(googleProvider)

Relevant Code:

// IMPORTANT: make sure you are connected to the emulator!!!

import firebase from 'firebase/app'

const provider = new firebase.auth.GoogleAuthProvider

// This happens out of band
auth.signInWithRedirect(provider)

// I don't think this is exceptional to me unlinking and
// relinking, but just in case...
async function unlinkAndRelink() {
  await firebase.auth().currentUser.unlink('google.com')
  await firebase.auth().currentUser.linkWithRedirect(provider)
}

Results

{"error":{"code":400,"message":"API key not valid. Please pass a valid API key.","errors":[{"message":"API key not valid. Please pass a valid API key.","domain":"global","reason":"badRequest"}],"status":"INVALID_ARGUMENT"}}"

Console: auth.esm.js?b7aa:219 GET https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=fake-api-key&cb=1610124371002 400

rosalyntan commented 3 years ago

Thanks for filing this issue! I've filed b/177944015 for internal tracking.