Search code examples
javagroovygoogle-appsgoogle-provisioning-api

Prevent user email delegation confirmation link


Currently, using the [deprecated] Google-apps APIs I can delegate email from one user's account to another account:

def gmailSettingsService = new GmailSettingsService(/* credentials... */)
gmailSettingsService.addEmailDelegate(userId, delegatedUserId)
// Email is now delegated, to remove:
gmailSettingsService.deleteEmailDelegate(userId, delegatedUserId)

The first time user A's email is delegated to user B, user B receives a confirmation email. Something to the effect of "So-and-so has granted you access to their email account--accept or deny?"

I would like to suppress this notification and bypass it altogether. I know this is possible with GAM. Does anyone know the appropriate code and settings to do this via the Java Apps-for-your-domain API?

Thanks!


Solution

  • The Email Settings API is not deprecated. You may have confused it with the deprecation of the Provisioning API (which is replaced by the Admin SDK Directory API). There is no replacement for the Email Settings API at this time, it's been around for awhile but is still supported.

    To answer your main question, the email approval flow is only performed when a user initiates the delegation from their Gmail web interface settings. If the delegation is performed via the API, the approval is immediate.

    However, if there's an existing or expired user-initiated delegation attempt in place between the two accounts, it must be cancelled in the user interface before performing the delegation via the API.