Does anyone know how to deny google login access by domain?

Hi guys!

I have to implement an app with google authentication. I read that I can use firebase to do it, but I can’t find information about to limit users access when they don’t belong to the domain.

As an example:
The domain is @example.com.
When I try to login with another domain as @gmail.com, the app have to deny the access unless the user belongs to the domain.

Is it possible to do it with firebase? Is it neccesary to use any additional library? If anyone knows how to solve it or about something that can help with that, I’ll be glad to read about it.

Firebase auth using the email provider will allow any domain to register

Using security rules u can restrict using domain name etc, at firebase end and app

Imho this is a pattern as they intend it to be

Thank you for your answer!!! Please, can you tell me how can I set the security rules? I was reading firebase documentation but I’m not so sure about the right process.

The google docs and other tutorials on firebase security rules r really good. I suggest ti search google for examples

R u using firestore or the realtime for the data?

I’m using a local API to get user’s info, and now I have to implement google login for those users. Those users have a custom email as user@example.com in google.
In this case, it would be right to connect the local API with google to get all email adresses, then get the first part of the email adress and send it as parameter to show user’s info?

Like this:

user@example.com —>user email

With an split function get just “user” and then compare with the local database. If “user” exists start the app and get user’s info.

If your users always have a google account then it is even easier. Just enable the google login provider in firebase settings and use the javascript library to get the uid and associated email adres

No need to use security rules

Not sure what u r aiming for