How do I determine if my account is a Google Apps account?

I am using the Google api docs list for .net V3 (dll version 2.0.1.0). I use login authentication as described in this link https://developers.google.com/google-apps/documents-list/#authorizing_requests_with_clientlogin

How do I determine if I have a Google Apps account or a regular Google account?

Thanks Bharat

+3
source share
4 answers

Consumer Google accounts @gmail.com or rarely @googlemail.com , the rest will be Google Apps accounts.

-4
source

If your goal is to check if the user has access to certain functionality, you can send a request to the metadata feed and check the <docs:feature> elements.

For example, a function with <docs:featureName>upload_any</docs:featureName> indicates that the user can upload any documents:

https://developers.google.com/google-apps/documents-list/#getting_general_information_about_a_users_account

+1
source

I don’t think there is a very good way to check if your account is a Google Apps account.

Checking if your email is different from @ gmail.com will not work because you can create Google accounts with existing email addresses.

The only thing I think about is to check the DNS records of the MX domain and see if any domain service is serviced by Google Apps servers (for example, email from gmail, etc.), but even where you can to check out several services because some Google Apps companies deactivate Gmail, for example (or some other service), instead of using a custom solution.

+1
source

Assuming you included:

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

in the OAuth area, you can make a request:

 https://www.googleapis.com/oauth2/v2/userinfo 

If this is a Google Apps account, the "hd" (Hosted Domain?) Parameter will be returned by a call with the Google Apps domain as the value. If this is a user account, be it @ gmail.com or even a potential “conflicting account”, the hd parameter will not be returned. See my example below. admin@jay.powerposters.org is the Google Apps account, and consumer@jay.powerposters.org is the user account. If I created a user user in the Google Apps domain, it would become a conflicting account, and the consumer account would be pushed out of the @ jay.powerposters.org namespace, but this has not happened yet.

For admin@jay.powerposters.org :

 GET https://www.googleapis.com/oauth2/v2/userinfo HTTP/1.1 200 OK Content-length: 99 X-xss-protection: 1; mode=block ... { "email": " admin@jay.powerposters.org ", "verified_email": true, "hd": "jay.powerposters.org" } 

For consumer@jay.powerposters.org :

 GET https://www.googleapis.com/oauth2/v2/userinfo HTTP/1.1 200 OK Content-length: 71 X-xss-protection: 1; mode=block { "email": " consumer@jay.powerposters.org ", "verified_email": true } 
+1
source

Source: https://habr.com/ru/post/920665/


All Articles