auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader                = "Authorization"
	XAuthorizationHeader               = "X-Authorization"
	ContentType                        = "application/x-www-form-urlencoded"
	Auth0Url                           = "https://auth.openai.com"
	LoginPasswordUrl                   = "https://auth0.openai.com/u/login/password?state="
	ParseUserInfoErrorMessage          = "Failed to parse user login info."
	SendOTPUrl                         = "https://api.openai.com/dashboard/onboarding/email-otp/send"
	OTPUrl                             = "https://api.openai.com/dashboard/onboarding/email-otp/validate"
	GetAuthorizedUrlErrorMessage       = "Failed to get authorized url."
	GetStateErrorMessage               = "Failed to get state."
	SendOTPErrorMessage                = "Failed to send OTP."
	EmailOrPasswordInvalidErrorMessage = "Email or password is not correct."
	GetAccessTokenErrorMessage         = "Failed to get access token."
	GetArkoseTokenErrorMessage         = "Failed to get arkose token."
)

Variables

View Source
var UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"

Functions

func NewHttpClient

func NewHttpClient(proxyUrl string) tls_client.HttpClient

Types

type AccountCookies

type AccountCookies map[string][]*http.Cookie

type AccountInfo

type AccountInfo struct {
	Account struct {
		AccountId   string `json:"account_id"`
		PlanType    string `json:"plan_type"`
		Deactivated bool   `json:"is_deactivated"`
	} `json:"account"`
}

type Error

type Error struct {
	Location   string
	StatusCode int
	Details    string
}

func NewError

func NewError(location string, statusCode int, details string) *Error

type OTPNotifier

type OTPNotifier func(email string) error

type OTPProvider

type OTPProvider func(email string) (string, error)

type Result

type Result struct {
	AccessToken string `json:"access_token"`
	PUID        string `json:"puid"`
	TeamUserID  string `json:"team_uid,omitempty"`
}

type UserID

type UserID struct {
	Accounts map[string]AccountInfo `json:"accounts"`
}

type UserLogin

type UserLogin struct {
	Username string
	Password string

	Result Result
	// contains filtered or unexported fields
}

func NewAuthenticator

func NewAuthenticator(emailAddress, password, proxy string) *UserLogin

func (*UserLogin) Begin

func (userLogin *UserLogin) Begin() *Error

func (*UserLogin) CheckPassword

func (userLogin *UserLogin) CheckPassword(state string, username string, password string) (string, int, error)

func (*UserLogin) CheckUsername

func (userLogin *UserLogin) CheckUsername(authorizedUrl string, username string) (string, int, error)

func (*UserLogin) GetAccessToken

func (userLogin *UserLogin) GetAccessToken() string

func (*UserLogin) GetAccessTokenInternal

func (userLogin *UserLogin) GetAccessTokenInternal(code string) (string, int, error)

func (*UserLogin) GetAuthResult

func (userLogin *UserLogin) GetAuthResult() Result

func (*UserLogin) GetAuthorizedUrl

func (userLogin *UserLogin) GetAuthorizedUrl(csrfToken string) (string, int, error)

func (*UserLogin) GetPUID

func (userLogin *UserLogin) GetPUID() (string, *Error)

func (*UserLogin) GetTeamUserID

func (userLogin *UserLogin) GetTeamUserID() (string, *Error)

func (*UserLogin) GetToken

func (userLogin *UserLogin) GetToken() (int, string, string)

func (*UserLogin) RefreshIOSToken

func (userLogin *UserLogin) RefreshIOSToken(refreshToken string) (string, *Error)

func (*UserLogin) RenewWithCookies

func (userLogin *UserLogin) RenewWithCookies() *Error

func (*UserLogin) ResetCookies

func (userLogin *UserLogin) ResetCookies()

func (*UserLogin) SaveCookies

func (userLogin *UserLogin) SaveCookies() *Error

func (*UserLogin) SetOTPCallbacks

func (userLogin *UserLogin) SetOTPCallbacks(notifier OTPNotifier, provider OTPProvider)

Jump to

Keyboard shortcuts

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