v0.10.5

OAuth Functions

Last updated


The function sets of core/oauth/copilot, core/oauth/codex, and core/oauth/grok.

Functions


FunctionCopilot (oauthCopilot)Codex / Grok
Loadfunc() (*llmrouter.CopilotToken, error)func() (*llmrouter.CodexToken, error) / func() (*llmrouter.GrokToken, error)
HasTokenfunc() boolfunc() bool
ClearTokenfunc() errorfunc() error
LoginWithCallbackfunc(ctx context.Context, onCode func(*DeviceCode)) (*llmrouter.CopilotToken, error)func(ctx context.Context, onURL func(string)) (*llmrouter.CodexToken, error) / (*llmrouter.GrokToken, error)
Login—Codex only: func(ctx context.Context, onURL func(string), onCode func(*DeviceCode)) (*llmrouter.CodexToken, error); runs the browser callback and device code logins at once and returns the first token, or both errors joined
LoginWithDeviceCode—Codex only: func(ctx context.Context, onCode func(*DeviceCode)) (*llmrouter.CodexToken, error)
Submit—Grok only: func(input string) error; completes a pending LoginWithCallback with a pasted authorization code or full callback URL
EnsureFresh—func(ctx context.Context, token *llmrouter.CodexToken) (*llmrouter.CodexToken, error) / GrokToken equivalent
EnsureFreshSessionfunc(ctx context.Context, token *llmrouter.CopilotToken, refresh *llmrouter.CopilotRefreshToken) (*llmrouter.CopilotRefreshToken, error)—

Copilot device-flow types


TypeFields
DeviceCodeDeviceCode, UserCode, VerificationURI, ExpiresIn, Interval; passed to onCode so the caller can show UserCode and VerificationURI
GopilotAccessTokenAccessToken, TokenType, Scope, Error; the access-token poll response of the device flow

Codex device-code type


TypeFields
DeviceCode (oauthCodex)VerificationURI, UserCode, ExpiresAt; passed to onCode so the caller can show where to enter UserCode and until when

Token types


The token types CopilotToken, CopilotRefreshToken, CodexToken, and GrokToken live in core; CodexToken and GrokToken expose Expired() bool.

中文