Search code examples
node.jsgoogle-apigoogle-oauth

Limiting emails for google signin api


What i wanna do is ..I am creating a application which accept only google sign in. But issue is that i want that only specific person get login with the google sign in.

like example only this kind of email like:

[email protected]

able to sign in having @company.edu.in at last but with google sign in. Not local sign in.


Solution

  • For now, your best option is to maintain the list on your side and once you get the id_token from Google, check to see if you want them to sign-in. If no then display an error message. At this point you can not add these restrictions to Google's side. If you know the domain of the users, you can pass the "hd" parameter in the oauth url. This will help users but they can still sign-in with a different account and you need to rely on the check on your side.

    Soon using firebase auth, you will be able to add restriction on which accounts can sign-in. So you should check that out as well.