Skip to main content

google-auth-core

Single source of truth for the ~/.google credential store, shared by the Google CLIs (gmail-cli, google-calendar-cli) and the Google Workspace MCP servers (gmail-mcp, gcal-mcp, gsheets-mcp, gdocs-mcp, gdrive-mcp).

What it provides

  • A unified per-account token store under ~/.google/tokens/google_<account>.json holding all scopes (Gmail + Calendar + Sheets + Docs + Drive + Contacts), so one consent covers every service for both CLIs and MCP servers.
  • Account management: default account, aliases (work, personal), env and directory overrides.
  • get_service(api, version, account): an authorized googleapiclient service, cached per (account, api, version) for persistent, multi-account-safe use.
  • A consistent error taxonomy (AuthError, NotFoundError, RateLimitError, InvalidArgumentError, UpstreamError) and map_http_error.

CLI

google-auth login [account]        # one-time OAuth, writes a unified token
google-auth login --readonly you@work.com   # read-only token, no writes possible
google-auth list                   # accounts, default, aliases
google-auth alias work you@work.com
google-auth status                 # token health per account
google-auth default you@work.com
google-auth logout you@work.com    # revoke at Google, then delete locally
google-auth logout --local-only you@work.com   # delete locally, skip revoke

Place your OAuth client (Desktop app) at ~/.google/credentials.json first. google-auth setup walks you through creating one; google-auth doctor checks an existing setup.

Avoid "Testing" status on the OAuth consent screen. Google expires refresh tokens after 7 days for an External app left in Testing, so you'd have to re-run google-auth login every week. Instead:

  • Google Workspace account: set the user type to Internal. No test users, no warning screen, tokens don't expire weekly. The Cloud project must belong to your Workspace organization, and only its accounts can sign in.
  • Personal Gmail, or accounts from several domains: use External, then click Publish app so the status is In production (no need to submit for verification). Each login shows an "unverified app" warning: click Advanced, then Go to (your app name) (unsafe). Google caps unverified apps at 100 users, which doesn't matter for personal use.

Already in Testing? Switch to In production and run google-auth login again for each account.

Which feature needs which scope

Feature Full login --readonly login
Gmail gmail.readonly, gmail.send, gmail.modify, gmail.settings.basic gmail.readonly
Calendar calendar calendar.readonly
Sheets spreadsheets spreadsheets.readonly
Docs documents documents.readonly
Drive drive drive.readonly
Contacts (search_contacts) contacts.readonly, contacts.other.readonly, directory.readonly same

Each feature also needs its API enabled in your Cloud project (the People API for Contacts); google-auth setup links to all of them.

Tokens from before Contacts existed keep working. They don't have its scopes, but get_credentials and check_token_health still treat them as healthy: the missing feature scopes are left out of the refresh request (asking Google for scopes it never granted fails with invalid_scope), so Gmail, Calendar, Sheets, Docs and Drive carry on. Only contact search fails, with Google's insufficient-scope error. google-auth status and google-auth doctor name what's missing:

you@work.com: valid
  contacts not granted. Run: google-auth login you@work.com to grant contacts

The same applies if you untick the contacts boxes on Google's consent screen: the login still succeeds and the token records only what you granted.

In code, missing_features(granted_scopes) and token_missing_features(account) return {feature: [missing scopes]}, empty when everything is covered.

Read-only login

google-auth login --readonly requests only the read-only scopes in the table above (gmail.readonly, calendar.readonly, spreadsheets.readonly, documents.readonly, drive.readonly and the three contacts scopes). The token itself cannot send mail, edit events, or change or delete files, whatever the MCP server or CLI tries. This is stronger than GOOGLE_MCP_READONLY, which only hides write tools.

The granted scopes saved in the token file record which set it holds (scope_set() returns full, readonly or partial). get_credentials and check_token_health treat a read-only token as healthy even when called with ALL_SCOPES, and status / doctor label it read-only. Writes fail with an AuthError that says the account is read-only: call require_write_access(account) before a write to fail early, or let the 403 from Google map to the same message. Run google-auth login <account> without the flag to upgrade to full access.

Logout

google-auth logout revokes the refresh token at Google (POST https://oauth2.googleapis.com/revoke) before deleting the local file, so a copied token stops working too. A token Google already treats as invalid is not an error. If Google cannot be reached, nothing is deleted; retry, or pass --local-only.

Metadata

Release files for google-auth-core 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for google-auth-core 0.3.2
File Size Uploaded Provenance Actions
google_auth_core-0.3.2.tar.gz 35.2 kB Without provenance Details for google_auth_core-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for google-auth-core 0.3.2
File Interpreter ABI Platform Actions
google_auth_core-0.3.2-py3-none-any.whl Python 3 none any Details for google_auth_core-0.3.2-py3-none-any.whl

Total release size: 65.1 kB

Release files / google_auth_core-0.3.2.tar.gz

Download URL google_auth_core-0.3.2.tar.gz
Size 35.2 kB
Tags Source
SHA-256 checksum
How to use checksums
87ca3c240dd90eaa590f7202a9cf4d43db224ce14654da3d3aca27e7c3d2708b
BLAKE2b-256 checksum
How to use checksums
8f6d6499bef773da2255c0b6adc2219d833acf569194be941d87b9fca1ba0a30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / google_auth_core-0.3.2-py3-none-any.whl

Download URL google_auth_core-0.3.2-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cacb239ac5031fc24262b2b2f2ba4543872126c58851bdf7c6e80e89ac4a36b
BLAKE2b-256 checksum
How to use checksums
c9c9db5076fd7eed3c40a372096854b81c43337be5f869fc8cb24444f40cf0c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for google-auth-core 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page