6
votes

I am using Google OAuth2.0, the requirement is only let G suite for Education account login, so I want to know what type of account user is using during the authentication.

The login part is finished, I get access token and refresh token, I asked for two scopes https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/userinfo.email

I checked the user profile, which can't help me to identify the type of account.

Can I differentiate these two type of account by only require above two scopes? if not, what other scopes I need to require and what API I need to use?

I found one example online, https://www.brainpop.com/ which supports what I mentioned.

The website only asks for Basic account info such as View your basic profile info and View your email address. When I log in using my personal Google account, then the login will be denied and tell me it's not G-suite education account.

Appreciate anyone's help.

2

2 Answers

0
votes

check email https://www.googleapis.com/auth/userinfo.email

IF EMAIL HAS CUSTOM DOMAIN LIKE ABC.COM then its gsuite if it is just gmail.com its not gsuite

0
votes

What I did do when I needed to know if the user was a G suite for education user was to also request the scope 'https://www.googleapis.com/auth/classroom.profile.photos'. If I remember correctly only users with a for education account would be asked for giving that permission. You can probably use any scope from the classroom API to (https://developers.google.com/classroom/reference/rest/).

I don't have this integration with Google anymore, so haven't tested it in about a year.