firebase / firebase/firebase-tools
"Invalid IdP response/credential" error using signInWithPopup with Google, Facebook, or Twitter providers and Firebase Emulators Suite
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:** 9.13.0
**Platform:** macOS 11.4
### [REQUIRED] Test case
My React web app can sign-in using the Google, Facebook & Twitter providers when connecting to production; however, I'm trying to use the Firebase Emulators Suite and upon signing-in using any of the providers, I get an `auth/internal-error` error.
### [REQUIRED] Steps to reproduce
1. Load Home screen, then this code is called:
```ts
import firebaseApp from 'firebase/app';
import 'firebase/auth';
...
const firebase = firebaseApp.initializeApp(config);
...
React.useEffect(() => {
if (process.env.NODE_ENV !== 'production') {
firebase.auth().useEmulator('http://localhost:9099');
}
}, []);
```
2. Click on Google icon, then this code is called:
`
const result = await firebase.auth().signInWithPopup(new firebaseApp.auth.GoogleAuthProvider());
`
3. Sign-in with valid user credentials to Popup window, then this `auth/internal-error` error is returned with:
`
message: Invalid IdP response/credential: https://my-react-app.firebaseapp.com/__/auth/handler?state=XXX&code=YYY&scope=ZZZ&authuser=2&prompt=none'
`
### [REQUIRED] Expected behavior
Expected call to return with a `Promise` object from Google Sign-in provider as per the documentation (https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signinwithpopup).
### [REQUIRED] Actual behavior
Thrown Error object: `{
code: "auth/internal-error",
message: "Invalid IdP response/credential: https://my-fake-app.firebaseapp.com/__/auth/handler?state=XXX&code=YYY&scope=ZZZ&authuser=2&prompt=none"
}`
Contributor guide
Assessment
This issue has not been assessed yet.