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§
- Browser
Config - Loopback OAuth2 callback settings.
- Drive
Auth Status - Secret-free presence/scope report, safe to serialise (e.g. over MCP).
- Drive
Credentials - Drive OAuth2 credentials.
- Drive
Session - A live Drive 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.
- Drive
Scope - 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.updateonname/parentsonly (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 isdrive auth logout. - save_
credentials - Saves Drive credentials to
~/.omni-dev/settings.json. - status
- Builds a
DriveAuthStatusfrom the current settings / environment.