Help us shape the future of Go! Take the 2026 Go Developer Survey

chatgpt

package
v0.2.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Issuer = "https://auth.openai.com"
View Source
const LocalRedirect = "http://127.0.0.1:1456/auth/callback"
View Source
const Profile = "chatgpt_plan"
View Source
const Resource = "https://api.openai.com/v1"

Variables

View Source
var ErrAuthorization = errors.New("ChatGPT authorization could not be verified; start sign-in again")
View Source
var ErrPermission = errors.New("ChatGPT plan usage was not authorized; enable plan usage and reconnect")
View Source
var ErrRefresh = errors.New("ChatGPT session expired or revoked; reconnect this account")
View Source
var ErrUnavailable = errors.New("ChatGPT plan connection is not configured")

Functions

func Digest

func Digest(value string) string

func LocalHelper added in v0.2.41

func LocalHelper(authorization, callback string) (string, error)

func Random

func Random() string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, config Config, client *http.Client) (*Client, error)

func (*Client) AuthorizationURL

func (c *Client) AuthorizationURL(state, nonce, verifier string, account ...string) string

func (*Client) Close

func (c *Client) Close()

func (*Client) Exchange

func (c *Client) Exchange(ctx context.Context, code, nonce, verifier string) (Credentials, error)

func (*Client) ExchangeRegistration added in v0.2.41

func (c *Client) ExchangeRegistration(ctx context.Context, code, nonce, verifier, expected, issued string) (Credentials, error)

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, current Credentials) (Credentials, error)

func (*Client) RegistrationID added in v0.2.41

func (c *Client) RegistrationID(expected, issued string) (string, error)

func (*Client) Revoke

func (c *Client) Revoke(ctx context.Context, current Credentials) error

type Config

type Config struct {
	ClientID         string
	ClientSecret     string `json:"-"`
	RedirectURL      string
	PlanUsageEnabled bool
	SelfHosted       bool
	HostID           string
}

func (Config) Accepts added in v0.2.41

func (c Config) Accepts(credentials Credentials) bool

func (Config) Available

func (c Config) Available() bool

func (Config) GoString

func (c Config) GoString() string

func (Config) LogValue

func (c Config) LogValue() slog.Value

func (Config) String

func (c Config) String() string

type Credentials

type Credentials struct {
	ClientID     string    `json:"client_id"`
	Subject      string    `json:"subject"`
	Email        string    `json:"email"`
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	IDToken      string    `json:"id_token"`
	Scopes       string    `json:"scopes"`
	Expiry       time.Time `json:"expiry"`
	HostID       string    `json:"ext_agent_host_id,omitempty"`
}

func (Credentials) GoString

func (c Credentials) GoString() string

func (Credentials) LogValue

func (c Credentials) LogValue() slog.Value

func (Credentials) String

func (c Credentials) String() string

func (Credentials) Valid

func (c Credentials) Valid(clientID string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL