LemonAi. Auth. GoogleGeminiCliOAuth
(lemon_ai v0.1.0)
View Source
Google Gemini CLI OAuth helpers.
Supports PKCE authorization URL generation, localhost callback/manual paste
parsing, token exchange + refresh, Code Assist project setup, encoded
secret payloads, and API-key resolution for the google_gemini_cli provider.
Summary
Functions
Build an OAuth authorization URL + PKCE verifier.
Build an OAuth authorization URL + PKCE verifier.
Decode OAuth secret payload.
Encode OAuth secret payload for storage by the caller.
Exchange authorization code + PKCE verifier for an OAuth secret payload.
Run the Gemini CLI OAuth flow.
Parse callback/manual pasted OAuth input. Accepts
Resolve a usable Gemini CLI credential JSON string ({"token","projectId"})
from a secret value.
Types
@type login_opt() :: {:on_auth, (String.t(), String.t() | nil -> any())} | {:on_progress, (String.t() -> any())} | {:on_prompt, (map() -> String.t() | charlist())} | {:redirect_uri, String.t()} | {:state, String.t()} | {:project_id, String.t()} | {:callback_timeout_ms, pos_integer()} | {:listen_for_callback, boolean()} | {:local_callback_listener, module()} | {:persist_secret, (String.t(), String.t() -> any())}
Functions
Build an OAuth authorization URL + PKCE verifier.
Build an OAuth authorization URL + PKCE verifier.
@spec decode_secret(String.t()) :: {:ok, oauth_secret()} | :not_oauth
Decode OAuth secret payload.
@spec encode_secret(oauth_secret()) :: String.t()
Encode OAuth secret payload for storage by the caller.
@spec exchange_code_for_secret(String.t(), String.t(), keyword()) :: {:ok, oauth_secret()} | {:error, term()}
Exchange authorization code + PKCE verifier for an OAuth secret payload.
@spec login_device_flow([login_opt()]) :: {:ok, oauth_secret()} | {:error, term()}
Run the Gemini CLI OAuth flow.
When the redirect URI is local (http://localhost:8085/oauth2callback by default),
A local listener can capture the browser callback automatically and fall back to manual
paste only if the listener cannot complete the flow.
@spec parse_authorization_input(String.t()) :: {:ok, %{code: String.t(), state: String.t() | nil}} | {:error, term()}
Parse callback/manual pasted OAuth input. Accepts:
- full callback URL
- query string containing
code= - plain code
Resolve a usable Gemini CLI credential JSON string ({"token","projectId"})
from a secret value.
Returns :ignore for non-Gemini-CLI OAuth payloads.