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:
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"{ "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:
| Area | Google scope | What it unlocks |
|---|---|---|
email | gmail.modify | Read, search, send, reply, label and trash Gmail messages |
calendar | calendar | Read and write events, RSVP, free-busy and availability |
files | drive.file | Files Zernio created and files the user picked. See Files |
contacts | contacts.readonly | A 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:
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
412account_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 reportserror, andaccount.disconnectedfires once withreasonCode: "auth_failed"andreconnectUrl, 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 sameaccountIdand clears the flags. - After connecting, Zernio subscribes to push notifications for the granted areas, and a
contactsconnection starts a contact sync. See Webhooks.
If it fails
| Error | Cause | Fix |
|---|---|---|
400 invalid_field_value, param: scopes | scopes is missing, empty or has an unknown area | Pass a subset of email, calendar, files, contacts. |
400 on loginHint | The value is not an email address | Pass the mailbox address, or leave it out. |
error=oauth_denied on the redirect | The user declined, or Google refused the app. platform_error carries Google's code | Start the connect again. admin_policy_enforced means the Workspace admin blocks the app: ask them to allow Zernio. |
error=invalid_state on the redirect | The link expired or was already used | Request a fresh authUrl. |
412 account_scope_missing on a later call | The area was not granted | Connect again with the area in scopes. |
Related
Connect a Google account and read and send Gmail, manage Google Calendar events, work with Google Drive files and sync Google Contacts through one Zernio API.
Organization connection
Let a Google Workspace admin grant Zernio access to the domain's mailboxes once, then add mailboxes through the API without each user signing in.