OverviewProductsPlatformsAPI ReferenceResources

Connect

Connect a Google account to a profile for any mix of Gmail, Google Calendar, Google Drive and Google Contacts, and widen it later.


Connect a Google account

Request the authorization link for a profile with the areas you need, then send the user to authUrl:

Terminal
curl "https://zernio.com/api/v1/connect/google?profileId=PROFILE_ID&scopes=email,calendar&redirect_url=https://example.com/done" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
JSON
{ "authUrl": "https://accounts.google.com/o/oauth2/v2/auth?client_id=…", "state": "…" }

The user picks a Google account and approves the permissions behind those areas. Zernio saves the account and redirects to redirect_url (or the dashboard) with connected=google, profileId, accountId and username (the mailbox address).

Choose the areas

scopes is required on Google. Pass a comma-separated subset of these areas:

AreaGoogle scopeWhat it unlocks
emailgmail.modifyRead, search, send, reply, label and trash Gmail messages
calendarcalendarRead and write events, RSVP, free-busy and availability
filesdrive.fileFiles Zernio created and files the user picked. See Files
contactscontacts.readonlyA read-only sync of Google Contacts into /v1/contacts

Every connection also asks for openid, userinfo.email and userinfo.profile, to identify the mailbox.

The directory area (people search across the Workspace directory) is not available on Google through Zernio's app yet, while Google reviews its scopes. It works with your own Google OAuth app, and on Microsoft.

Ask only for what your product uses. Google's consent screen lists each permission, and Workspace admins review apps by what they request.

Add areas later

To add an area, connect the same Google account again with the new list. Google keeps the areas granted earlier, and Zernio updates the same account, so its accountId does not change.

Areas only accumulate. Leaving one out of a reconnect does not remove it. To drop an area, disconnect the account and connect it again with the areas you want.

Pass reconnectAccountId to make sure the reconnect lands on a given account (Zernio then also asks again for the areas that account holds).

Also pass loginHint with the mailbox address to preselect it in Google's account picker:

Terminal
curl "https://zernio.com/api/v1/connect/google?profileId=PROFILE_ID&scopes=email,calendar,files&loginHint=ana@example.com&reconnectAccountId=ACCOUNT_ID" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"

Connect from the dashboard

In the dashboard, the Google tile opens a chooser with the four areas, all ticked for a new account and the granted ones for a reconnect.

The consent screen then asks only for the ticked areas.

From the API the flow has no Zernio screen: your app chooses the areas, and the user sees only Google's account picker and consent screen.

How it behaves

  • One Google account is one Zernio account per profile. Connecting it again updates that account instead of adding a second one.
  • A new Google account is asked for exactly the areas in scopes, whatever other Google accounts on the profile hold.
  • Zernio records the areas Google actually granted. If the user unticks a permission on Google's consent screen, that area is left out of the account and calls in it answer 412 account_scope_missing.
  • Access renews by itself. When Google answers a renewal with invalid_grant (the user removed Zernio from their Google account, or the grant expired), Zernio asks once more and then marks the account disconnected: isActive: false, needsReconnection: true, account health reports error, and account.disconnected fires once with reasonCode: "auth_failed" and reconnectUrl, a hosted link valid for seven days. A timeout, a throttle (429) or a Google outage never disconnects an account. Reconnecting the same Google account reactivates it with the same accountId and clears the flags.
  • After connecting, Zernio subscribes to push notifications for the granted areas, and a contacts connection starts a contact sync. See Webhooks.

If it fails

ErrorCauseFix
400 invalid_field_value, param: scopesscopes is missing, empty or has an unknown areaPass a subset of email, calendar, files, contacts.
400 on loginHintThe value is not an email addressPass the mailbox address, or leave it out.
error=oauth_denied on the redirectThe user declined, or Google refused the app. platform_error carries Google's codeStart the connect again. admin_policy_enforced means the Workspace admin blocks the app: ask them to allow Zernio.
error=invalid_state on the redirectThe link expired or was already usedRequest a fresh authUrl.
412 account_scope_missing on a later callThe area was not grantedConnect again with the area in scopes.
Was this page helpful?

On this page