LemonAi. Auth. GoogleAntigravityOAuth
(lemon_ai v0.1.0)
View Source
Google Antigravity OAuth helpers.
Supports PKCE authorization URL generation, localhost callback/manual paste parsing, token exchange + refresh, encoded secret payloads, and API-key resolution.
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 Google Antigravity OAuth flow.
Parse callback/manual pasted OAuth input. Accepts
Resolve a usable Google Antigravity API key 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()} | {:email, 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.
Defaults to a localhost callback URI (http://localhost:51121/oauth-callback).
Build an OAuth authorization URL + PKCE verifier.
Defaults to a localhost callback URI (http://localhost:51121/oauth-callback).
@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.
project_id may be passed in options; defaults to a fallback project.
@spec login_device_flow([login_opt()]) :: {:ok, oauth_secret()} | {:error, term()}
Run Google Antigravity OAuth flow.
When the redirect URI is local (http://localhost:51121/oauth-callback by default),
A local listener can capture the browser callback automatically and fall back to manual
paste only if that 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 Google Antigravity API key JSON string ({"token","projectId"})
from a secret value.
Returns :ignore for non-Antigravity-OAuth payloads.