timkmecl / chatgpt-vscode

VSCode extension that allows you to use ChatGPT or GPT4 inside the IDE
340 stars 81 forks source link

I've been doing some testing regarding 403 errors #7

Closed SolsticeSpectrum closed 1 year ago

SolsticeSpectrum commented 1 year ago

So I dug into it and realized that even copying cookies from browser to browser using cookie management addons is tricky. Basically It would never accept the cookie as valid and just show me login page. But I made a breakthrough.

image

It seems that all these 3 cookies are essential to get logged. For example callback-url value if not same as it was with that specific session token will invalidate the session token. Host auth token also is important. And one BIG important thing is that all three cookies NEED to have Lax sameSite policy and they NEED to be Session cookies. Now surprisingly you don't need expiration date on the session token.

Also the cloudflare cookies are supposed to be on .chat.openai.com domain, the dot is also important it seems. Other than that you only need cf_clearance, the other two cookies will get generated again.

So yeah just the session token isn't enough

timkmecl commented 1 year ago

Hi, thanks a lot for sharing your experiment! I will look into this.

timkmecl commented 1 year ago

@DarkReaper231 This has now been solved using a method described in this tweet (simple Node.js implementation here), already implemented in the unofficial chatgpt api. Only the official API key from OpenAI needed.