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 someone@somadomain.com, 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, someone@hotmail.com, which has no domain restriction when sharing a file.
Can anyone help with this? Thanks!
Assuming you included:
in your OAuth scopes, you can make a request to:
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. admin@jay.powerposters.org is a Google Apps Account while consumer@jay.powerposters.org 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 admin@jay.powerposters.org:
For consumer@jay.powerposters.org: