I used to assess whether or not a domain had Google Apps or not by doing a CURL request to "http://www.google.com/a/{domain}/" and checking for this string "[sign in here for the control panel]", if it had it, it had Google Apps, if it didn't than they didn't have Google Apps.
But recently Google switched to the universal http://admin.google.com login page, and it made no distinction between domains. Now this obviously breaks how I used to check to see if it had Google Apps.
Does anyone have any other work-arounds to do this?
I tried a few URL's from Google API's, but they require Auth...
NOTE: I do not wish to check via MX/TXT records, I need to check if they have Google Apps, not if they are using it. The reason for this is I had developed a Google Apps Toolkit that did a series of checks and gave the status of a domain, the old method I used to test if a domain had Google Apps was 100% accurate, every other online Google Apps tester I used was fairly inaccurate due to them checking MX records. I don't want to fall into this trap. This was very helpful for domains that used to have Google Apps but moved to another provider and want to move back to a reseller (It happens more often than you would think, I work for a reseller)
I have successfully figured it out!
To determine if a domain has Google Apps purchased on it, just do the following:
Do a CURL request to: "https://www.google.com/a/{domain}/ServiceLogin"
Search for the following string: "Sorry, you've reached a login page for a domain that isn't using", if it contains that string, it does not have Google Apps, if it doesn't have that string than it does contain Google Apps.
An example PHP function (I'm using file_get_contents instead of CURL on this example because it is shorter, please note you will need to enable URL based locations in php.ini)
function lookupGoogleAccount($domain) {
$url = "https://www.google.com/a/$domain/ServiceLogin";
$extpage = file_get_contents($url);
$not_gapps = strpos($extpage,"Sorry, you've reached a login page for a domain that isn't using");
return !$not_gapps;
}
Example: https://gapps.qk.com.au/?domain=never.io
Using this method even if the domain is a reseller and using a custom SSO solution it should continue to work.
Working further on this I've found one new way to check if a domain is part of a G Suite console. The solution is to use the customers.get method of the G Suite Reseller API.
As the documentation explains, to you use this API you need to be a G Suite reseller and have access to a reseller console.
This can almost be considered as an official Google solution as when you use it on a domain, if it is part of a G Suite console, as answer you get the primary domain of the console of which the domain you are checking is part (see the screenshot below).
You can check domains in bulk using this tool. Disclaimer: I am the author of it.
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