gencay / vscode-chatgpt

An unofficial Visual Studio Code - OpenAI ChatGPT integration
ISC License
3.5k stars 760 forks source link

Im getting error 403 Fobidden #16

Closed DrMemoryFish closed 1 year ago

DrMemoryFish commented 1 year ago

Error loading webview: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state.

An error occurred. If the issue persists try 'ChatGPT: Clear session.'

I get the above error codes. I've refreshed and cleared many times.

gregid commented 1 year ago

I started getting 403 Forbidden yesterday evening - I wondered if anyone else is having similar problem. I assumed OpenAI may have throtthled access from outside of their web ui. I didn't have ServiceWorker error though (just 403).

xichen-de commented 1 year ago

I also started getting 403 Forbidden today. The problem persists even after deleting the session. Looks like OpenAI is restricting access.

Joey0x646576 commented 1 year ago

According to the creator of chatgpt-api they added additional cloudflare protection.

To bypass this you need two additional properties; cf_clearance and user-agent. While this works, it's only available for a limited time, before you need to refresh your cf_clearance token.

This package is not updated with the latest chatgpt-api, but if you update the dependencies and build it yourself it will still function.

gencay commented 1 year ago

Hi - yes, there have been multiple changes on the openai side. I am working on a resolution

gencay commented 1 year ago

Update: ChatGPT servers are completely down right now that blocks development progress. I will update again if/when I find a resolution for our extension. Thanks all for the patience!

gencay commented 1 year ago

Update: Hang tight, the VSCode marketplace package seems to not include puppeteer built-in chromium. Thus there are run-time errors in the extension. WIP

Hi everybody,

I've a fix for the recent 403 issue and it's being rolled out right now. Please watch out the version 1.7.1 on marketplace 🎉

The new workflow logs you in automatically without needing to copy paste the cookies onto the extension:

Let the login flow automatically run:

Since OpenAI servers are experiencing issues, please expect intermittent login failures / outage messages on openai website during auto-login flow.

This is the first attempt to overcome the 403 errors. Let me know if you face issues. I will keep the Issue open until we are good with the current solution.

raifpy commented 1 year ago

What about OAuth?

gencay commented 1 year ago

Mitigation in place: Add your session cookies and userAgent manually. You can grab these from session cookies cf_clearance and __Secure-next-auth.session-token + run this in console to get your User Agent: navigator.userAgent.

I'm working on an auto-login flow which I mentioned in my earlier message. This will be much neater than refreshing those cookies manually. The v1.7.2 now works when you provide session-token, cf_clearance and userAgent variables. image

gregid commented 1 year ago
Run the following command in Console to find your user agent: navigator.userAgent. Enter the content of this value when prompted by the extension.

I would change it to:

Run the following command in (web browser) Console to find your user agent: navigator.userAgent. Enter the content of this value when prompted by the extension (no single or double quotes).
GitHdu commented 1 year ago

Update: Hang tight, the VSCode marketplace package seems to not include puppeteer built-in chromium. Thus there are run-time errors in the extension. WIP

Hi everybody,

I've a fix for the recent 403 issue and it's being rolled out right now. Please watch out the version 1.7.1 on marketplace 🎉

The new workflow logs you in automatically without needing to copy paste the cookies onto the extension:

  • Enter your email address
  • Enter your password (We don't store anything, all personal information remains locally on your vs-code)

Let the login flow automatically run:

  • It'll open a new chrome instance and use the credentials you provided to automatically login and grab the required fields from your cookie.

Since OpenAI servers are experiencing issues, please expect intermittent login failures / outage messages on openai website during auto-login flow.

This is the first attempt to overcome the 403 errors. Let me know if you face issues. I will keep the Issue open until we are good with the current solution.

still getting 403 forbidden

curtisreynolds57 commented 1 year ago

Update: Hang tight, the VSCode marketplace package seems to not include puppeteer built-in chromium. Thus there are run-time errors in the extension. WIP Hi everybody, I've a fix for the recent 403 issue and it's being rolled out right now. Please watch out the version 1.7.1 on marketplace 🎉 The new workflow logs you in automatically without needing to copy paste the cookies onto the extension:

  • Enter your email address
  • Enter your password (We don't store anything, all personal information remains locally on your vs-code)

Let the login flow automatically run:

  • It'll open a new chrome instance and use the credentials you provided to automatically login and grab the required fields from your cookie.

Since OpenAI servers are experiencing issues, please expect intermittent login failures / outage messages on openai website during auto-login flow. This is the first attempt to overcome the 403 errors. Let me know if you face issues. I will keep the Issue open until we are good with the current solution.

still getting 403 forbidden

I believe he hasn't released the fix, yet.

gencay commented 1 year ago

I did release the fix and the new flow that requires session token, clearance token and user agent. Check the Readme.md for getting those.

gencay commented 1 year ago

The issues seem to be happening for some users of the downstream API wrapper we are using. There is an active discussion here: https://github.com/transitive-bullshit/chatgpt-api/issues/96#issuecomment-1350275343. Some people reported that getting the required tokens and user-agent using a different browser than Chrome helped them bypass the 403 issues.

Noppey commented 1 year ago

Still 403 unfortunately. None of the restrictions that are mentioned in that comment are applicable.

Tried with Edge: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46

Tried with Chrome and Brave: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Tried with node 18 and 19. No proxy, no other fancy stuff.

gencay commented 1 year ago

Hello everybody,

I released a new version that supports automated authentication 🚀

Check out the release notes and the Readme on how to enable this setting. image

This is still an experimental setting, thus not a default. If y'all could try out the new feature it'd be great!

Once I get enough confirmation, I will make this the default way to use the extension.

curtisreynolds57 commented 1 year ago

Hello everybody,

I released a new version that supports automated authentication 🚀

Check out the release notes and the Readme on how to enable this setting. image

This is still an experimental setting, thus not a default. If y'all could try out the new feature it'd be great!

Once I get enough confirmation, I will make this the default way to use the extension.

The servers are down right now, but I was testing this out earlier. It said something along the lines of "there's no field for #username." I'll see if I can replicate it when the servers go back up, but it seems puppeteer doesn't know how to input the username

gencay commented 1 year ago

Yes, servers are occasionally down today.

I am working on a zero-config setup. The extension will open chrome and will let you login as usual. Once login flow is complete, the extension will then grab the tokens automatically for you and close the chrome.

This way you won't need to provide any usernanme, password nor chrome path(it will pick up from default chrome installation path, with an option to override).

Zero config on the way!

curtisreynolds57 commented 1 year ago

I see that. I'm still getting 403 forbidden, even from the auto login. I have looked at all of the requirements, such as updating Node js, not opening the client while trying to connect, etc.

gencay commented 1 year ago

The Zero-Config setup is rolled out with v1.8.3. On this version you have the option to have automatic authentication using puppeteer. If you haven't used it yet, Clear your session and run a prompt; it will automatically open Chrome and you should login as usual. Once you land on chat page, the browser will be automatically closed and you will be authenticated using the tokens off of that session.

Though there are still 403 issues with OpenAI APIs since they throttle programmatic access.

curtisreynolds57 commented 1 year ago

Yeah, even with the manual login, it's still giving me 403 forbidden.

Noppey commented 1 year ago

Is it possible to provide some logging output of the OpenAI Api when getting the 403? This way we can provide this logging to transitive-bullshit github as well, as that's probably where this has to be solved.

gencay commented 1 year ago

I've been away on vacation for a few weeks, and I updated the extension to utilize the browser for ChatGPT queries. Make sure to keep the Chrome browser open after successful login (previously it was closing automatically causing 429 for subsequent questions). Whenever you restart your vs-code or close the Chrome instance please make sure to log-in again to keep an active ChatGPT connection. The extension will use the browser behind the scenes for your queries.

Since v2 will resolve this issue, I am closing it. Please update to latest on marketplace. Thanks for all the engagement and patience.

fyi @Noppey @gregid @Joey0x646576 @GitHdu