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

chatgpt

package
v0.2.40 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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Issuer = "https://auth.openai.com"
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 requires an approved OpenAI OAuth client")

Functions

func Digest

func Digest(value string) string

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) 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) Refresh

func (c *Client) Refresh(ctx context.Context, current Credentials) (Credentials, 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
}

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"`
}

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