Documentation
¶
Overview ¶
Package openaiauth implements renewable ChatGPT subscription OAuth credentials. It deliberately delegates persistence and login presentation to the host application.
Index ¶
- Constants
- func ExchangeAuthorizationCode(ctx context.Context, config Config, ...) (tokenResponse, error)
- type AuthorizationRequest
- type Config
- type DeviceCode
- type Manager
- func (m *Manager) Apply(ctx context.Context, request *http.Request) error
- func (m *Manager) CompleteAuthorization(ctx context.Context, code, verifier, redirectURI string) (llmauth.Credential, error)
- func (m *Manager) LoginDevice(ctx context.Context, onCode func(DeviceCode)) (llmauth.Credential, error)
- func (m *Manager) Logout(ctx context.Context) error
- func (m *Manager) RecoverUnauthorized(ctx context.Context) error
- func (m *Manager) Status(ctx context.Context) (llmauth.Credential, error)
Constants ¶
View Source
const ( DefaultIssuerURL = "https://auth.openai.com" // DefaultClientID is the public client identifier used by the OpenAI Codex // device and browser authorization flows. Hosts may override it in Config. DefaultClientID = "app_EMoamEEZ73f0CkXaXp7hrann" DefaultScope = "openid profile email offline_access api.connectors.read api.connectors.invoke" )
View Source
const Provider = "openai_subscription"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthorizationRequest ¶
func NewAuthorizationRequest ¶
func NewAuthorizationRequest(config Config, redirectURI string) (AuthorizationRequest, error)
type DeviceCode ¶
type DeviceCode struct {
VerificationURL string
UserCode string
DeviceAuthID string
Interval time.Duration
}
func RequestDeviceCode ¶
func RequestDeviceCode(ctx context.Context, config Config) (DeviceCode, error)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager serializes refresh and logout for one credential profile. Hosts should reuse a manager per profile and coordinate refreshes separately if credentials are shared across processes.
func NewManager ¶
func (*Manager) CompleteAuthorization ¶
func (m *Manager) CompleteAuthorization(ctx context.Context, code, verifier, redirectURI string) (llmauth.Credential, error)
CompleteAuthorization exchanges a browser callback code. The host must first verify that the callback state matches AuthorizationRequest.State.
func (*Manager) LoginDevice ¶
func (m *Manager) LoginDevice(ctx context.Context, onCode func(DeviceCode)) (llmauth.Credential, error)
func (*Manager) RecoverUnauthorized ¶
Click to show internal directories.
Click to hide internal directories.