Google OAuth Setup
msgvault requires OAuth credentials to access the Gmail API. This guide walks through the complete setup.
Step 1: Create a Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Note your project ID
Step 2: Enable the Gmail API
- Navigate to APIs & Services > Library
- Search for “Gmail API”
- Click Enable
Step 3: Configure OAuth Consent Screen
- Go to APIs & Services > OAuth consent screen
- Choose External user type (or Internal for Google Workspace)
- Fill in required fields:
- App name:
msgvault - User support email: your email
- Developer contact email: your email
- App name:
- Click Save and Continue
- On the Scopes page, click Add or Remove Scopes
- Add the scope:
https://www.googleapis.com/auth/gmail.modify - Save and continue through the remaining screens
- Under Test users, add all Gmail addresses you want to sync
Step 4: Create OAuth Client Credentials
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Choose Desktop application
- Name it
msgvault Desktop Client - Click Create
- Download the JSON file
- Save it as
client_secret.jsonin a secure location
Step 5: Configure msgvault
Create ~/.msgvault/config.toml:
[oauth]client_secrets = "/path/to/your/client_secret.json"
[sync]rate_limit_qps = 5Step 6: Add Your Account
msgvault add-account you@gmail.comThis opens your browser to Google’s OAuth consent page. Sign in, grant access, and tokens are stored locally in ~/.msgvault/tokens/.
Headless Server Setup
When running msgvault on a headless server (SSH, VPS, Docker), there is no browser available for the standard OAuth flow. Use the device authorization flow instead:
msgvault add-account you@gmail.com --headlessThis displays instructions:
Starting device code flow...
1. Open this URL in any browser: https://www.google.com/device
2. Enter this code when prompted: ABC-XYZ
Waiting for authorization...- Run the command above on the server
- Open
https://www.google.com/deviceon any device with a browser (phone, laptop) - Sign in to your Google account
- Enter the displayed code
- Grant access to msgvault
- The server automatically detects authorization and stores the token
Once authorized, all other commands work normally. Tokens are stored in ~/.msgvault/tokens/you@gmail.com.json and refreshed automatically.