I am working on an app that allows user to share their Drive files to friends. But there is a problem of Google App Account, like [email protected]
, of which files cannot be shared with people who are not under that domain. Although the share policy can be changed by admin of somedomain.com
, but I prefer not allowing people use my app with Google Apps Account.
I also check this post: How to determine if the account is a Google apps account?. But I don't agree with the idea of checking domain to detect account type. Because people can register Google Account with any email address. I just registered one with my Hotmail, [email protected]
, which has no domain restriction when sharing a file.
Can anyone help with this? Thanks!
To find your domains, sign in to Google Domains with the Google account you used to register your domains. “My domains” lists each domain you own.
Options for finding a user accountSign in to your Google Admin console. Sign in using your administrator account (does not end in @gmail.com). Users. Locate the user in the list and click the name to open their account page.
Assuming you included:
https://www.googleapis.com/auth/userinfo.email
in your OAuth scopes, you can make a request to:
https://www.googleapis.com/oauth2/v2/userinfo
If it's a Google Apps account, an "hd" parameter (Hosted Domain?) will be returned by the call with the Google Apps domain as it's value. If it's a consumer account, whether it's @gmail.com or even a potential "conflicting account", the hd parameter will not be returned. See my example below. [email protected] is a Google Apps Account while [email protected] is a consumer account. If I created a consumer user in the Google Apps domain it wouuld become a conflicting account and the consumer account would be pushed out of the @jay.powerposters.org namespace but that hasn't happened yet.
For [email protected]:
GET https://www.googleapis.com/oauth2/v2/userinfo
HTTP/1.1 200 OK
Content-length: 99
X-xss-protection: 1; mode=block
...
{
"email": "[email protected]",
"verified_email": true,
"hd": "jay.powerposters.org"
}
For [email protected]:
GET https://www.googleapis.com/oauth2/v2/userinfo
HTTP/1.1 200 OK
Content-length: 71
X-xss-protection: 1; mode=block
{
"email": "[email protected]",
"verified_email": true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With