Documentation
¶
Index ¶
- Constants
- Variables
- type Access
- type Client
- type ClientOptions
- type Credential
- type CredentialStore
- func (s *CredentialStore) Load(ctx context.Context) (Credential, error)
- func (s *CredentialStore) Update(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)
- func (s *CredentialStore) UpdateRefresh(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)
- type DeviceAuthorization
- type RefreshStore
- type Source
- type Store
Constants ¶
const ( Issuer = "https://auth.openai.com" ClientID = "app_EMoamEEZ73f0CkXaXp7hrann" LoginTimeout = 10 * time.Minute )
Variables ¶
var ErrNotLoggedIn = errors.New("codex: account disconnected; run sol auth login ENTRY --method codex")
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access struct{ Token, AccountID, ComputeResidency string }
Access contains the current bearer token and its Codex routing metadata.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements device authentication and a refreshable Source.
func NewClient ¶
func NewClient(opts ClientOptions) (*Client, error)
NewClient validates explicit dependencies without accessing the store.
func (*Client) Access ¶
Access reloads credentials under the store's transaction lock. Refresh token rotation is committed before another process may refresh or send a request.
func (*Client) CompleteDeviceAuth ¶
func (c *Client) CompleteDeviceAuth(ctx context.Context, device DeviceAuthorization) (Credential, error)
CompleteDeviceAuth is bounded even when the caller has no deadline. It returns credentials without persisting them; callers explicitly commit successful login.
func (*Client) StartDeviceAuth ¶
func (c *Client) StartDeviceAuth(ctx context.Context) (DeviceAuthorization, error)
StartDeviceAuth creates a device attempt and returns the browser instructions.
type ClientOptions ¶
type ClientOptions struct {
HTTPClient *http.Client
Issuer string
ClientID string
UserAgent string
// Store must also implement RefreshStore so accepted token rotations can
// commit independently of caller cancellation.
Store Store
}
ClientOptions requires an explicit HTTP client, protocol identity and store. HTTP issuer URLs support local test servers; production uses Issuer.
type Credential ¶
type Credential = localconfig.OAuthCredential
type CredentialStore ¶
type CredentialStore struct {
// contains filtered or unexported fields
}
CredentialStore scopes all credential operations to one named OpenAI account.
func NewStore ¶
func NewStore(store localconfig.Store, entry string) (*CredentialStore, error)
func (*CredentialStore) Load ¶
func (s *CredentialStore) Load(ctx context.Context) (Credential, error)
func (*CredentialStore) Update ¶
func (s *CredentialStore) Update(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)
func (*CredentialStore) UpdateRefresh ¶
func (s *CredentialStore) UpdateRefresh(ctx context.Context, change func(*Credential) (*Credential, error)) (*Credential, error)
type DeviceAuthorization ¶
type DeviceAuthorization struct {
DeviceAuthID string
UserCode string
VerificationURL string
PollInterval time.Duration
}
DeviceAuthorization is a transient login attempt, never a persisted credential.
type RefreshStore ¶
type RefreshStore interface {
Store
UpdateRefresh(context.Context, func(*Credential) (*Credential, error)) (*Credential, error)
}
type Store ¶
type Store interface {
Load(context.Context) (Credential, error)
Update(context.Context, func(*Credential) (*Credential, error)) (*Credential, error)
}