I'm following the steps here to try and add Google sign-in to a project that uses. firebase auth.
data-fetcher-dev.firebaseapp.com is included in Firebase authorized domains.My code:
firebase.initializeApp({
apiKey: 'AIzaSyCp8i_9lHCyLOREMIPSUM21342xXmb0F0Y',
authDomain: 'data-fetcher-dev.firebaseapp.com',
projectId: 'data-fetcher-dev',
});
const googleProvider = new firebase.auth.GoogleAuthProvider();
googleProvider.addScope('profile');
googleProvider.addScope('email');
...
const signInWithGoogle = async () => {
try {
const result = await firebase.auth().signInWithPopup(googleProvider);
console.log('result: ', result);
} catch (error) {
console.log('error: ', error);
}
};
signInWithGoogle is called when a button is pressed. A new tab opens and I am able to select a Google account/ sign in to one:
After selecting an account I am redirected to a URL like https://data-fetcher-dev.firebaseapp.com/__/auth/handler?state=LONG_TOKEN_VALUE&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&authuser=3&prompt=consent and the page just loads forever:
I am using firebase hosting so there is an empty project at https://data-fetcher-dev.firebaseapp.com. Do I need to implement a backend route at /__/auth/handler? I thought Firebase was supposed to handle that for me, as they do not mention it in the docs.
Thanks in advance.