简体   繁体   中英

How do I enable Google sign-in for my Android app such that it only allows users from a specific Google domain?

I have currently integrated stock Google sign-in for my app. I now want it to restrict sign-in from only one specific Google domain. eg john.doe@xyz.com. I only want users from the xyz domain to be able to sign in. I'm guessing there is a better solution than regex matching. I have read about openid connect for sign-in but I'm only finding info related to web apps.

I would limit the user input to be only the e-mail address before the @. I would create a TextView (or something) to hold the domain I want people to use and place it on the side of the EditText . This would make people insert only what comes before the @. I would limit the use of certain characters as well (@, for example). And last, I would add the domain I want people to use when they pressed the login button.

String domain = "@xyz.com";
String login = editText.getText() + domain;

Yeah, something like this. But well done and well thought.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM