modulepackage
0.0.0-20221211072658-a31e0587361e
Repository: https://github.com/rodjunger/chatgptauth.git
Documentation: pkg.go.dev
# README
ChatGPTAuth provides requests-based authentication for the OpenAI ChatGPT website.
Extra care was put to ensure that requests match the browser requests in every aspect to avoid blocks, but you still may get rate limit.
It is currently in a VERY wip state, things can and will change.
Installation
go get -u github.com/rodjunger/chatgptauth
Pre-built binaries
Pre-built binaries are not available currently, a CLI is planned.
Lib usage
Check the full example including captcha handling on example/main.go
func main() {
// Don't use zerolog.DebugLevel to log to console, it will make the output unreadable
logger := log.Output(zerolog.ConsoleWriter{Out: os.Stdout}).Hook(OnlyInfoHook{}).Level(zerolog.InfoLevel)
auth, err := chatgptauth.NewAuthClient("user", "password", "", &logger)
if err != nil {
log.Error().Err(err).Msg("Failed to create auth client")
return
}
captcha, err := auth.Begin()
if err != nil {
log.Error().Err(err).Msg("Failed to begin auth")
return
}
var answer string
if captcha.Available() {
// Solve the captcha
answer = ""
}
creds, err := auth.Finish(answer)
if err != nil {
log.Error().Err(err).Msg("Failed to finish auth")
return
}
logger.Info().Str("Access token", creds.AccessToken).Str("Expiry", creds.ExpiresAt).Msg("logged in")
//Save credentials to file so you don't have to login again next time
}
Thank you
This lib was made possible by the reverse engineering work of rawandahmad698, my own reverse engineering work (big shoutout to charles proxy), and the awesome maintainers of all libraries used in this project.
# Packages
No description provided by the author
# Functions
NewAuthClient creates a new authenticator, performing valiation on the parameters.
# Structs
Auth contains the state for an authenticated user's session.
No description provided by the author
# Type aliases
No description provided by the author