m1guelpf / chatgpt-telegram

Run your own GPTChat Telegram bot, with a single command!
MIT License
3.88k stars 560 forks source link

Some Suggestion about "without session token" #27

Open EricMeteorite opened 1 year ago

EricMeteorite commented 1 year ago

A small suggestion is that maybe this program can use OpenAI's user email and password as a config file, and also maybe can try to let the program "Automatically grab Session Token", so that it can be used without a session token and without popping up a browser window? Is that OK to be achieved?

And, thank you so much for your contribution!

EricMeteorite commented 1 year ago

Also, It would be great if you could add a Terminal-like function to the program. We don’t need to restart the program through the server or host every time. We can restart the program at any time by calling Terminal to restart through telegram.

acheong08 commented 1 year ago

@EricMeteorite OpenAI's email/password authentication system is pretty complex and changes quite often. I've got a solution in Python but its very difficult to maintain.

acheong08 commented 1 year ago

It has a total of 8 different parts to it and occasional captcha which also needs to be handled

EricMeteorite commented 1 year ago

@acheong08 Got it, thanks, it is really not very convenient to realize this function.

acheong08 commented 1 year ago

If anyone needs some reference code, https://github.com/acheong08/OpenAIAuth currently works. I hope this feature gets added to the bot

GitHub
GitHub - acheong08/OpenAIAuth: OpenAI Authentication Library for ChatGPT
OpenAI Authentication Library for ChatGPT. Contribute to acheong08/OpenAIAuth development by creating an account on GitHub.
rodjunger commented 1 year ago

If anyone needs some reference code, https://github.com/acheong08/OpenAIAuth currently works. I hope this feature gets added to the bot

GitHubGitHub - acheong08/OpenAIAuth: OpenAI Authentication Library for ChatGPTOpenAI Authentication Library for ChatGPT. Contribute to acheong08/OpenAIAuth development by creating an account on GitHub.

I'll work on a golang version of that, should be done by tomorrow.

GitHub
GitHub - acheong08/OpenAIAuth: OpenAI Authentication Library for ChatGPT
OpenAI Authentication Library for ChatGPT. Contribute to acheong08/OpenAIAuth development by creating an account on GitHub.
acheong08 commented 1 year ago

Thank you @rodjunger

rodjunger commented 1 year ago

Thank you @rodjunger

No problem! Just hit the first milestone, got a full login working with only requests in go (including saving the captcha to a png and sending the response in the request), I will clean things up a bit and upload it to a repository in the next hour (or after brazils game in the world cup).

There's plenty of error checking in the code but basically no logging, just some debug prints. It shouldn't take a lot of time to add that tho.

acheong08 commented 1 year ago

got a full login working with only requests in go

How did you bypass their client fingerprinting?

acheong08 commented 1 year ago

I'm having trouble porting it to pure requests in Python

rodjunger commented 1 year ago

got a full login working with only requests in go

How did you bypass their client fingerprinting?

In Golang it's easier to spoof TLS and http2 fingerprints since everything is implemented in go (no openssl or external libs), I used a library called mimic which creates a patched roundTripper that mimics chrome. I also made a small script on python to convert headers from charles proxy to go so I could have the exact same headers as the browser in the same order in case they fingerprinted that too.

With that said, it's probably not possible to get it working with pure requests if they're actually fingerprinting all of that.

acheong08 commented 1 year ago

With that said, it's probably not possible to get it working with pure requests if they're actually fingerprinting all of that.

Got it. It does seem they're doing that for Auth0.

rodjunger commented 1 year ago

WIP version uploaded to github:

https://github.com/rodjunger/chatgptauth

GitHub
GitHub - rodjunger/chatgptauth: GoLang library to authenticate with the ChatGPT service through api interactions
GoLang library to authenticate with the ChatGPT service through api interactions - GitHub - rodjunger/chatgptauth: GoLang library to authenticate with the ChatGPT service through api interactions