Gmail Authorization
Gmail access requires your own Google Cloud OAuth client. Local configuration validation does not test this connection.
1. Create a Google Cloud Project
- Follow the instructions to Create a Google Cloud Project (or use an existing one).
- I used
tidy-gmail-gcloud-projectfor the name and nothing for the organization. - Click Create.
2. Create a Google Cloud Project
Follow the setup sections in Google's Gmail Python quickstart.
2A. Enable the API
- Go to Google Cloud.
- Click "Console".
- You may see the project you just created, if not select it.
- Using the Python Quickstart instructions, click Enable the Gmail API.
2B. Configure the OAuth consent screen
- Click Go to Branding.
- Click Get Started.
- App name = tidy-gmail
- User support email = your gmail (you are the only user of your app).
- Click Next.
- Audience = External.
- Click Next.
- Contact information = your gmail.
- Click Next.
- Finish: Read and check the box.
- Click Continue.
- Click Create.
OAuth audience: Select External, even if you are the only user. Add your Gmail address as a test user while testing. For continued personal use, consider switching the publishing status to In production because Testing-mode Gmail refresh tokens expire after seven days. Google provides a verification exception for personal-use applications. Each tidy-gmail user creates and manages their own OAuth client; no shared developer credentials are required.
2C. Authorize credentials for a desktop application
- In the Python Quickstart, click "Go to Clients".
- Click + Create Client.
- Application type = Desktop app.
- For Name, type a name for the credential.
I used
tidy-gmail Local Desktop OAuth Client. - Leave the AI-powered agent box unchecked.
- Click Create.
- IMPORTANT: Click Download JSON.
- Save the downloaded JSON file as credentials.json
in your tidy-gmail/.local directory, e.g.,
C:\Repos\analytics-toolworks\tidy-gmail\.local\credentials.json. - Click OK.
Use tidy-gmail's commands below instead of the quickstart's sample script.
3. Store Credentials Locally
Save the downloaded JSON as .local/credentials.json in your workspace.
Keep it out of Git and shared archives.
Follow Local privacy to restrict access.
Do not manually create token.json.
4. Add yourself as a test user
- Open Google Cloud / Google Auth Platform / Audience.
- Ensure your tidy-gmail-gcloud-project project is selected and select if necessary.
- Under Test users, click + Add users.
- Enter your gmail.
- Click Save.
5. Authorize and Scan
Published-package users run:
uvx tidy-gmail scan --limit 100
Developers using this checkout run:
uv run tidy-gmail --workspace "C:\Repos\analytics-toolworks\tidy-gmail" scan --limit 100
The authorization flow opens a browser when needed. Choose the Gmail account intended for this workspace. Click Continue on the unverified screen.
Successful will show: The authentication flow has completed. You may close this window.
The application requests gmail.modify for inspection and later
Trash/restoration operations.
Scanning itself does not modify Gmail.
Successful authorization saves .local/token.json
for subsequent commands.
After scanning, run report,
review sender decisions,
and run candidates,
using the same command prefix and workspace.
Keep one Gmail account per workspace.
Receipt Protection After Authorization
Receipt protection uses decoded Subject metadata from the existing
gmail.modify authorization. No new permission or reauthorization is
required for this feature. Scanning remains read-only for Gmail.
See Receipt protection before cleanup.