Expand description
Google Gemini (Code Assist) OAuth: authorization-code + PKCE.
Experimental. The user-facing endpoints (accounts.google.com/o/oauth2/v2/auth,
oauth2.googleapis.com/token) are official Google OAuth 2.0 surfaces. The
Code Assist runtime host (cloudcode-pa.googleapis.com/v1internal) that
consumes the resulting access token is a product-client-observed integration
surface and is treated as experimental — it is not described as a stable
public third-party API.
Credential mapping:
OAuthCredentials.refresh= long-lived Google refresh token (broker-owned only)OAuthCredentials.access= short-lived Google access tokenOAuthCredentials.expires= access-token expiry (ms, with skew)
The long-lived refresh token must never be vended, logged, or placed in broker wire types. This module operates only inside the auth boundary.
Structs§
Enums§
- Gemini
Auth Error - Secret-safe login/refresh errors — variants intentionally store neither tokens, codes, nor client-secret material so Display cannot leak them.
Constants§
- AUTHORIZE_
URL - Google installed-app OAuth authorization endpoint (RFC 6749).
- CALLBACK_
HOST - Loopback callback host; RFC 8252 § 7.3 mandates a literal IP for installed
apps. Google explicitly rejects
localhostfor some client types. - CALLBACK_
PATH - Callback path — pinned distinct from the shared
/callbackto avoid state bleed with the other loopback providers. - CALLBACK_
PORT - Default loopback port for the Gemini callback listener.
- CLIENT_
ID_ ENV - Environment variable containing the Synaps-owned Google Desktop OAuth client registration used for Gemini Code Assist.
- CLIENT_
SECRET_ ENV - Optional installed-app client value paired with
CLIENT_ID_ENV. Desktop registrations are public clients; this value is configuration, not a confidential secret, but it still must not be logged or committed here. - CONNECT_
TIMEOUT - Connect timeout for auth HTTP.
- EXPIRY_
SKEW_ MS - Expiry safety-margin subtracted from
now + expires_in. - MAX_
RESPONSE_ BODY_ BYTES - Maximum response body bytes we will accept from Google OAuth endpoints.
- PROVIDER
- Canonical storage / broker id.
- REQUEST_
TIMEOUT - Full request timeout for auth HTTP.
- SCOPES
- Space-separated scopes. Same values as the official Gemini CLI reference: cloud-platform (Code Assist), userinfo.email, userinfo.profile.
- TOKEN_
URL - Google OAuth 2.0 token endpoint.
- USERINFO_
URL - Google userinfo endpoint (for optional post-auth account labeling).
Functions§
- build_
authorize_ url - Build a Google installed-app authorization URL with PKCE (S256), offline access, and forced consent so a refresh token is always issued.
- credentials_
from_ token_ response - login
- Interactive login against the production Google OAuth endpoints.
- login_
with_ registration - Interactive login with injectable seams — pinned to production URLs by
default; a test harness may override the token endpoint (and set
allow_http_token_endpoint = true) to talk to a loopback OAuth fake. - parse_
pasted_ callback - Parse a manually pasted Google OAuth loopback callback URL. Strict:
requires http/127.0.0.1/exact-port/exact-path, both
codeandstate, and exact state equality — never defaults a missing state. - redirect_
uri - Build the loopback redirect URI for the Gemini OAuth flow. Always emits a
literal loopback IP (RFC 8252 §7.3) — never
localhost. - refresh_
token - Refresh grant against the production Google token endpoint.
- refresh_
with_ registration - Refresh grant with an overridable token endpoint. Public for zero-network
harness use only — production callers must go through
refresh_token.