Reputation: 997
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)
Upvotes: 4
Views: 4232
Reputation: 1540
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.
Upvotes: 1
Reputation: 997
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.
Upvotes: 13
Reputation: 1540
The answer by Mattisdada is not 100% reliable.
There could be the case where a given domain has been activated and validated so it is possible to reach it trough the "https://www.google.com/a/{domain}/ServiceLogin" as suggested, but this does not means that it is actually using the google apps.
The best solution I could find is to check the MX records looking for the google ones. As this is a php question the best option is to use the getmxrr function.
Upvotes: -1