Connect your personal Google account for Gmail, Calendar, and Drive.
Overview
Google OAuth connects your personal Google account. Sign in and choose which permissions to grant your agents.
Best for:
- Personal Gmail inbox
- Your calendar
- Personal Drive files
- Sending emails as yourself
How it works
11. Click Connect → Redirect to Google sign-in22. Review scopes → Choose what to allow33. Approve → Tokens are encrypted and stored44. Done → Your agents can access the approved servicesConnecting
- Go to Settings → Secrets → Integrations
- Find Google Account and click Connect
- Sign in with your Google account
- Review the requested permissions
- Click Allow
You'll be redirected back to inference.sh with your integration active.
Adding permissions
Already connected but need more access? Add permissions incrementally:
- Open your connected Google OAuth integration
- Click Add Permissions
- Select the capabilities you need (e.g., Gmail, Calendar)
- You'll be redirected to Google to approve the new scopes
- Return to inference.sh with updated permissions
This uses Google's incremental authorization — your existing permissions are preserved.
Available capabilities
Gmail
| Capability | Description | Use case |
|---|---|---|
google.gmail.readonly | Read emails | Summarize inbox, search messages |
google.gmail.send | Send emails | Send notifications, replies |
Calendar
| Capability | Description | Use case |
|---|---|---|
google.calendar.readonly | Read events | Check availability, list meetings |
google.calendar | Read/write events | Create meetings, update events |
Drive
| Capability | Description | Use case |
|---|---|---|
google.drive.readonly | Read files | Access personal documents |
google.drive | Read/write files | Create and edit files |
Sheets & Docs
| Capability | Description | Use case |
|---|---|---|
google.sheets.readonly | Read spreadsheets | Analyze data |
google.sheets | Read/write spreadsheets | Update data |
google.docs.readonly | Read documents | Extract content |
google.docs | Read/write documents | Edit documents |
Security
| Feature | Benefit |
|---|---|
| Minimal scopes | Only request what you need |
| Token encryption | OAuth tokens are encrypted at rest |
| Auto-refresh | We handle token expiration automatically |
| Revocable | Disconnect anytime |
Revoking access
You can revoke access two ways:
- From inference.sh: Settings → Integrations → Disconnect
- From Google: myaccount.google.com/permissions
Using in apps
Declare OAuth requirements in your app:
1integrations:2 - key: google.gmail.send3 description: Send order confirmations4 5 - key: google.calendar.readonly6 description: Check your availability7 optional: trueAt runtime, your app receives:
1GOOGLE_OAUTH_ACCESS_TOKEN=ya29...2GOOGLE_OAUTH_TOKEN_EXPIRES_AT=2024-01-15T10:30:00ZExample: Send an email
1import base642from email.mime.text import MIMEText3from googleapiclient.discovery import build4from google.oauth2.credentials import Credentials5 6creds = Credentials(token=os.environ["GOOGLE_OAUTH_ACCESS_TOKEN"])7service = build('gmail', 'v1', credentials=creds)8 9message = MIMEText("Hello from my agent!")10message['to'] = "[email protected]"11message['subject'] = "Automated message"12 13raw = base64.urlsafe_b64encode(message.as_bytes()).decode()14service.users().messages().send(15 userId='me',16 body={'raw': raw}17).execute()Example: List calendar events
1from googleapiclient.discovery import build2from google.oauth2.credentials import Credentials3 4creds = Credentials(token=os.environ["GOOGLE_OAUTH_ACCESS_TOKEN"])5service = build('calendar', 'v3', credentials=creds)6 7events = service.events().list(8 calendarId='primary',9 maxResults=10,10 singleEvents=True,11 orderBy='startTime'12).execute()13 14for event in events.get('items', []):15 print(event['summary'], event['start'])Troubleshooting
"Token expired" or "Invalid credentials"
- We auto-refresh tokens, but if the refresh token is revoked, you'll need to reconnect
- Go to Settings → Integrations and reconnect your Google account
"Insufficient permission"
- The requested scope isn't granted
- Use Add Permissions to request the missing capability
- Apps will prompt you if they need scopes you haven't granted
"Access blocked: This app's request is invalid"
- This usually means the OAuth configuration has an issue
- Contact support if this persists
Gmail not working but other services are
- Gmail requires specific scopes (
gmail.readonlyorgmail.send) - Check that you've granted the Gmail-specific permissions
OAuth vs Service Account
| Feature | OAuth | Service Account |
|---|---|---|
| Setup | Sign in with Google | Get email, share files |
| Access model | Your personal account | Shared file access |
| Best for | Gmail, Calendar, personal files | Team spreadsheets, shared docs |
| Token management | Auto-refresh | Auto-generated |
Use OAuth for personal services. Use Service Account for team resources.