I am using Expo Google Sign in to authorize users inside my app, but in organization I would like to restrict it to only users from a particular domain, for example: @yourcompany.com, how can I do it?
In the past, I believe there was a way to do this by adding a query parameter to your request. But a user can override it by using the
You can find more details here. I haven’t personally tried this solution, so please let me know how it goes.
If this is important to you, you may have to write your own authentication middleware to intercept authentication requests and whitelist domains.
Thanks for the advice, I sure had some thought about it and I come up with two solutions.
Solution 1 (based on yours):
Use Expo’s AuthSession object (wiith hd (Hosted domain) parameter to make OAuth request, but this take has some sideeffects like you need to make another request to get accessToken and refreshToken via serverAuthCode. It is indeed pure OAuth flow, but you need to make sure to get it yourself.
Use Expo’s Google object to authorize the user, on success check email (with RexEx) from profile information, if it maches then let user go further, if not throw new Error().
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.