Google sign in custom domain
const provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
hd: "example.com"
});const signIn = () => {
const provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
hd: "wsj.com"
});
firebase
.auth()
.signInWithPopup(provider)
.then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
console.log("signed-in", user);
// ...
})
.catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
console.log("error", error);
// ...
});
};Last updated
Was this helpful?