Skip to content

GoLang library to authenticate with the ChatGPT service through api interactions

License

Notifications You must be signed in to change notification settings

rodjunger/chatgptauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

GoLang library to authenticate with the ChatGPT service through api interactions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages