Expand description
Gmail OAuth2 authentication: authorization-code + PKCE login, credential storage, and in-memory access-token refresh.
See ADR-0063 for the design rationale.
The loopback-listener + browser-launch shape follows the Snowflake
client’s external-browser SSO flow (crate::snowflake::client’s private
auth module), extended with PKCE (RFC 7636), a state nonce, and an
error= branch — none of which a static-token or SSO-only flow needs.
Structs§
- Browser
Config - Loopback OAuth2 callback settings.
- Gmail
Auth Status - Secret-free presence/scope report, safe to serialise (e.g. over MCP).
- Gmail
Credentials - Gmail OAuth2 credentials.
- Gmail
Session - A live Gmail OAuth2 session: holds the refresh token and the current in-memory access token, refreshing on demand.
Enums§
- Browser
Launch - How to open the authorization URL during login.
- Gmail
Scope - The Gmail OAuth2 scope granted at login.
Constants§
- GMAIL_
API_ URL - Environment variable overriding the real Gmail API host.
- GMAIL_
CLIENT_ ID - Environment variable / settings key for the user’s Google Cloud OAuth2 client id.
- GMAIL_
CLIENT_ SECRET - Environment variable / settings key for the user’s Google Cloud OAuth2 client secret.
- GMAIL_
REFRESH_ TOKEN - Environment variable / settings key for the stored OAuth2 refresh token.
- GMAIL_
SCOPE - Environment variable / settings key recording the scope granted at login.
- SCOPE_
MODIFY - Read-write Gmail scope — required for label add/remove; opt-in.
- SCOPE_
READONLY - Read-only Gmail scope — the default.
Functions§
- load_
credentials - Loads Gmail credentials from environment variables or settings.json.
- login
- Runs the OAuth2 authorization-code + PKCE login flow, persisting the
resulting refresh token to
~/.omni-dev/settings.json. - remove_
credentials - Removes Gmail credential keys from
~/.omni-dev/settings.json— this isgmail auth logout. - save_
credentials - Saves Gmail credentials to
~/.omni-dev/settings.json. - status
- Builds a
GmailAuthStatusfrom the current settings / environment.