ffc
ffc

Reputation: 51

How to check if Gmail is turn on for a user in G Suite?

Scenario 1: According to this article: Remove a G Suite service: An administrator can uninstall Gmail for all users.

Scenario 2: According to this article: Turn Gmail on or off for a group of users: An administrator can put a user in an organization unit and turn on/off Gmail for the organization.

My question is: how to check if Gmail is turned on/off for a user in G Suite by Google API? (both Scenario 1 & Scenario 2)

I know that if I send API https://www.googleapis.com/gmail/v1/users/me/labels by the user in Scenario 2, I'll get a response like

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "failedPrecondition",
                "message": "Mail service not enabled"
            }
        ],
        "code": 400,
        "message": "Mail service not enabled"
    }
}

But I'm afraid that this response is not specific enough and the message "Mail service not enabled" may vary as time goes by.

Upvotes: 0

Views: 1000

Answers (1)

ffc
ffc

Reputation: 51

Directory API, Users resource, isMailboxSetup can be used for checking the mail service

Indicates if the user's Google mailbox is created. This property is only applicable if the user has been assigned a Gmail license.

My test result:

  • a normal user's isMailboxSetup with Gmail service eanbled: true
  • a suspended user's isMailboxSetup: true
  • the user's isMailboxSetup in scenario 1 (uninstall Gmail for all users): false
  • the user's isMailboxSetup in scenario 2 (turn off Gmail for the organization): false

Upvotes: 1

Related Questions