Quick reference
| Property | Value |
|---|---|
| Platform value | gmail |
| One connected account | One Gmail mailbox. |
| Supported | Mailbox reads, folders, drafts and controlled sending |
| Features | Email ✓ |
| Provider approval | Google OAuth verification; restricted mail scopes require applicable security assessment and customer consent |
| Token | Access token plus refresh token (renewed automatically) |
Before you start
The person connecting needs:
- A Google account with Gmail.
- While your Google app is unverified: added as a test user on the OAuth consent screen.
You (the platform owner) need:
- In console.cloud.google.com create (or reuse) a project and a Web application OAuth client; copy its Client ID and Client secret.
- Enable the Gmail API.
- Authorized redirect URI: https://YOUR_DOMAIN/auth/callback/gmail
- On the OAuth consent screen, add your Google account as a test user while the app is unverified.
Permissions (scopes)
Techrace puts these permissions in the login link. The person approves them on the provider's own screen; only approved permissions are granted.
| Permission | Requested by default | Used for |
|---|---|---|
openid | Yes | Identify the Google account |
email | Yes | Read the account's email address |
https://www.googleapis.com/auth/gmail.readonly | Yes | Read messages, threads and labels |
https://www.googleapis.com/auth/gmail.compose | Optional | Create drafts |
https://www.googleapis.com/auth/gmail.send | Optional | Send mail |
https://www.googleapis.com/auth/gmail.modify | Optional | Change labels, archive, trash |
Connect an account
/api/v1/projects/{project_id}/connect-sessionsconnections:writeCreate a connect link with provider "gmail" and send the person's browser to the returned url. return_url is the page in your app where they land afterwards (https, or http://localhost while testing).
curl -X POST "https://YOUR_DOMAIN/api/v1/projects/$TECHRACE_PROJECT_ID/connect-sessions" \
-H "Authorization: Bearer $TECHRACE_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<EOF
{
"customer_id": "$CUSTOMER_ID",
"provider": "gmail",
"return_url": "https://your-app.com/integrations/done"
}
EOFAfter approval the person lands on your return_url with ?connected=gmail&customer_id=…&connection_id=…, or ?error=access_denied|expired|failed&provider=gmail. Your webhook also receives account.connected. Keep the connection_id: every call below uses it.
Read and send mail
/api/v1/projects/{project_id}/email/queryemail:readRead messages, threads, folders and attachments.
/api/v1/projects/{project_id}/email/operationsemail:send / email:drafts:write / email:modifyCreate drafts, send, reply, forward and organise mail. See the Email group in the API reference for each action's fields.
Limitations
- Signing in to Techrace with Google does not connect Gmail; it is a separate connection.
- Sending requires the restricted gmail.send scope.
Common errors
| Error | Meaning | Fix |
|---|---|---|
unsupported_email_oauth_scope | A scope outside the allowed Gmail list was configured. | Use only gmail.readonly, send, compose or modify. |
account_reconnection_required | The refresh token is no longer valid. | Reconnect the mailbox. |