Home > Software engineering >  Login with Google custom email only
Login with Google custom email only

Time:01-29

I'm building a React app where you have to login in order to access certain pages. There are a few restrictions:

  • it should be 'login with google' button
  • only custom emails should be accepted ([email protected]) All custom emails are G suit emails.

So far I'm thinking about Firebase, but not sure how to validate email in this case.

Is Firebase the right tool for this use case? If so how to validate emails in this case?

Or there is a better approach?

Thanks in advance!

CodePudding user response:

Yes! Firebase is perfect for this usecase. Follow the instructions here to setup google auth. https://firebase.google.com/docs/auth/web/google-signin

Once you've configured your provider with:

const provider = new GoogleAuthProvider();

Add the custom parameters and pass in the 'hd' key with your domain as value. (hd stands for hosted domain)

provider.setCustomParameters({
  'login_hint': '[email protected]',
  'hd': 'example.com'
});

Learn more about the custom parameters here: https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters

  •  Tags:  
  • Related