Skip to main content

Module auth

Module auth 

Source
Expand description

Drive OAuth2 authentication: authorization-code + PKCE login, credential storage, and in-memory access-token refresh.

See ADR-0069 for the design rationale (applying ADR-0063, Gmail’s OAuth2 credential-storage design, to a second Google API). The loopback-listener and browser-launch shape follows crate::gmail::auth, itself following 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§

BrowserConfig
Loopback OAuth2 callback settings.
DriveAuthStatus
Secret-free presence/scope report, safe to serialise (e.g. over MCP).
DriveCredentials
Drive OAuth2 credentials.
DriveSession
A live Drive OAuth2 session: holds the refresh token and the current in-memory access token, refreshing on demand.

Enums§

BrowserLaunch
How to open the authorization URL during login.
DriveScope
The Drive OAuth2 scope granted at login.

Constants§

DRIVE_API_URL
Environment variable overriding the real Drive API host.
DRIVE_CLIENT_ID
Environment variable / settings key for the user’s Google Cloud OAuth2 client id.
DRIVE_CLIENT_SECRET
Environment variable / settings key for the user’s Google Cloud OAuth2 client secret.
DRIVE_REFRESH_TOKEN
Environment variable / settings key for the stored OAuth2 refresh token.
DRIVE_SCOPE
Environment variable / settings key recording the scope granted at login.
SCOPE_METADATA
Drive’s narrowest write scope: files.update on name/parents only (rename/move), no file-content access. Opt-in via --write.
SCOPE_READONLY
The read-only Drive scope — the default.

Functions§

load_credentials
Loads Drive 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 Drive credential keys from ~/.omni-dev/settings.json — this is drive auth logout.
save_credentials
Saves Drive credentials to ~/.omni-dev/settings.json.
status
Builds a DriveAuthStatus from the current settings / environment.