Google OAuth credentials are not baked into the build. You must create your own OAuth credentials through Google Cloud Console. This is a one-time setup that takes about 10 minutes.
Overview
Craft Agents integrates with Google services (Gmail, Calendar, Drive, Docs, Sheets) using OAuth 2.0 with PKCE (Proof Key for Code Exchange). Your credentials are stored encrypted locally using AES-256-GCM encryption.Prerequisites
- A Google account
- Access to Google Cloud Console
- 10 minutes for initial setup
Complete Setup Guide
Create a Google Cloud Project
- Go to Google Cloud Console
- Click Select a project → New Project
- Enter a project name (e.g., “My Craft Agent”)
- Click Create
- Note your Project ID for reference
Enable Required APIs
Go to APIs & Services → Library and enable the APIs you need:
Gmail API
Gmail API
For email integration
- Read, send, and manage email
- Create and manage drafts
- Label and organize messages
- Mark messages as read/unread
Google Calendar API
Google Calendar API
For calendar integration
- View and manage calendar events
- Create and update events
- Manage calendar access
Google Drive API
Google Drive API
For file storage integration
- Access and manage files
- Upload and download documents
- Share and organize folders
You can enable multiple APIs for the same project. Enable only the APIs you plan to use.
Configure OAuth Consent Screen
- Go to APIs & Services → OAuth consent screen
- Select External user type (unless you have Google Workspace)
- Click Create
- App name: e.g., “My Craft Agent”
- User support email: Your email address
- Developer contact information: Your email address
- Click Save and Continue
- Scopes: Skip this step (click Save and Continue)
- Test users: Add yourself as a test user
- Click Add Users
- Enter your Google email
- Click Add
- Click Save and Continue
- Review and click Back to Dashboard
Create OAuth Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth Client ID
- Application type: Select Desktop app
- Name: e.g., “Craft Agent Desktop”
- Click Create
- A dialog appears with your credentials:
- Client ID:
something.apps.googleusercontent.com - Client Secret:
your-client-secret
- Client ID:
- Click Download JSON (optional, for backup)
- Copy both the Client ID and Client Secret
Keep your Client Secret secure. Never commit it to version control or share it publicly.
OAuth Flow
When you authenticate:- Browser opens to Google consent screen
- Sign in with your Google account
- Review permissions and click Allow
- Redirected back to Craft Agent
- Tokens stored encrypted in
~/.craft-agent/credentials.enc
Scopes by Service
Gmail Scopes
Gmail Scopes
https://www.googleapis.com/auth/gmail.modify- Read, trash, labels, mark read/unreadhttps://www.googleapis.com/auth/gmail.compose- Create and send draftshttps://www.googleapis.com/auth/userinfo.email- Access email address
Calendar Scopes
Calendar Scopes
https://www.googleapis.com/auth/calendar- Full calendar accesshttps://www.googleapis.com/auth/userinfo.email- Access email address
Drive Scopes
Drive Scopes
https://www.googleapis.com/auth/drive- Full Drive accesshttps://www.googleapis.com/auth/userinfo.email- Access email address
Docs Scopes
Docs Scopes
https://www.googleapis.com/auth/documents- Full Docs accesshttps://www.googleapis.com/auth/userinfo.email- Access email address
Sheets Scopes
Sheets Scopes
https://www.googleapis.com/auth/spreadsheets- Full Sheets accesshttps://www.googleapis.com/auth/userinfo.email- Access email address
Token Refresh
Google access tokens expire after 1 hour. Craft Agent automatically refreshes them using the refresh token:- Access tokens are refreshed automatically before API calls
- Refresh tokens are long-lived (no expiration)
- Your credentials are stored securely for automatic refresh
Security Notes
Troubleshooting
Error: Google OAuth not configured
Error: Google OAuth not configured
You haven’t provided OAuth credentials. Either:
- Provide
clientIdandclientSecretin source config - Set
GOOGLE_OAUTH_CLIENT_IDandGOOGLE_OAUTH_CLIENT_SECRETenvironment variables (development only)
Error: Access blocked - This app's request is invalid
Error: Access blocked - This app's request is invalid
Your OAuth consent screen is not properly configured:
- Verify you added yourself as a test user
- Check that required APIs are enabled
- Ensure redirect URI matches (should be
http://localhost:{port}/callback)
Error: OAuth state mismatch
Error: OAuth state mismatch
Possible CSRF attack detected. This can happen if:
- You have multiple OAuth flows running simultaneously
- Your system time is incorrect
- You’re behind a proxy that modifies requests
Token refresh fails
Token refresh fails
Refresh token might be invalid:
- Re-authenticate to get a new refresh token
- Ensure
offline_accessandprompt=consentare used during OAuth (automatic in Craft Agent) - Check that Client ID and Client Secret are stored correctly
Environment Variables (Development)
For development/testing, you can set OAuth credentials as environment variables:.env
Environment variables serve as a fallback. User-provided credentials in source config take precedence.