chatgpt-vscode
chatgpt-vscode copied to clipboard
Error: ChatGPT failed to refresh auth token: 403 forbidden
Looks like the extension is currently broken due to downstream issues. https://github.com/transitive-bullshit/chatgpt-api/issues/96
i got the Same Error. i tried it with diffrent session tokens. :(
This error is due to additional CloudFlare protection added by OpenAI, however it can be circumvented (with limitations) by extracting three parameters from the web version (instead of just sessionToken
) as described here.
I have this implemented in my fork, and have also already published the updated version to the VSCode Marketplace, so if you only want to use the extension just update it and enter the new parameters as described in the readme.md
.
Hope this helps!
Same here.
This error is due to additional CloudFlare protection added by OpenAI, however it can be circumvented (with limitations) by extracting three parameters from the web version (instead of just
sessionToken
) as described here.I have this implemented in my fork, and have also already published the updated version to the VSCode Marketplace, so if you only want to use the extension just update it and enter the new parameters as described in the
readme.md
.Hope this helps!
I followed these steps and am still getting the 403
@hsavit1 @timkmecl Same here. Followed all the steps outlined and I'm still getting 403. Made sure the session token, clearance token, and user agent were properly filled in, but same 403 error.
Huh that's weird. I just retested it and it still works fine here. I am usingEdge on Windows 10, and my user-agent
is 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
.
Would you mind sharing your OS, browser and user-agent to see if we can determine the cause of the issue?
Huh that's weird. I just retested it and it still works fine here. I am usingEdge on Windows 10, and my
user-agent
isMozilla/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
. Would you mind sharing your OS, browser and user-agent to see if we can determine the cause of the issue?
Still getting 403 error. For user-agent, did you put 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
or 108.0.0.0
?
The whole text, i.e. 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
(but make sure you use your own, not just copy mine)
This error is due to additional CloudFlare protection added by OpenAI, however it can be circumvented (with limitations) by extracting three parameters from the web version (instead of just
sessionToken
) as described here. I have this implemented in my fork, and have also already published the updated version to the VSCode Marketplace, so if you only want to use the extension just update it and enter the new parameters as described in thereadme.md
. Hope this helps!I followed these steps and am still getting the 403
in my case, I use Fedora 37. I did the Cloudflare steps but it still continues with the problems I pointed out earlier. It works normally directly on the Chat GPT website.
Could you please check what node version you have installed (node -v
)?
There may be a problem with chatgpt-api for versions<18
Could you please check what node version you have installed (
node -v
)? There may be a problem with chatgpt-api for versions<18
Could you tell me which browser you use? And maybe paste your user-agent
I'm also still having the issue , using @timkmecl fork, I'm on Chrome , my user-agent
is Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
I just retested it using Chrome (previously I was on Edge) and it works too. Honestly I have currently no idea why it works for some and not for the others, if anyone knows something or finds out a solution either for the users or for me to implement please let me know!
Could you tell me which browser you use? And maybe paste your user-agent
TBH my use case could be not really reflecting other users, I'm trying to get the extension work with GitPod (gitpod.io) :)
This is the request send (stripped out my tokens) :
accept
:
"*/*"
accept-language
:
"en-US,en;q=0.9"
cookie
:
"cf_clearance=removed; __Secure-next-auth.session-token=removed"
origin
:
"https://chat.openai.com"
referer
:
"https://chat.openai.com/chat"
sec-ch-ua
:
"\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\""
sec-ch-ua-platform
:
"\"macOS\""
sec-fetch-dest
:
"empty"
sec-fetch-mode
:
"cors"
sec-fetch-site
:
"same-origin"
user-agent
:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
x-openai-assistant-app-id
:
""
In chat.openai.com I see other cookies being passed like __Host-next-auth.csrf-token
...
I also just tested with my VS Code and same issue
just tried it after upgrading everything still getting error 403
Could you tell me which browser you use? And maybe paste your user-agent
Version 108.0.5359.99 (Official Build) (64-bit) Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
I will paste my answer from my fork here which shows some new info:
It looks like this problem is not limited to this project, but also to some other ones using chatgpt-api, probably caused by agressive CloudFlare protection. In my own testing, even when I tried to login to my account in Chrome right after using it inside Edge, I got a 403 error inside the web version. After I waited for several minutes and tried again, it disappeard, but this shows that the problem is not just with the javascript API.
The browser that you use for getting the tokens might influence the chance to get 403, especially chrome, so maybe try from another one (https://github.com/transitive-bullshit/chatgpt-api/issues/107#issuecomment-1349712906)
There might also be some account or IP flagging going on either by OpenAI or CloudFlare that increases the possibility of getting 403 especially if doing lots of requests often (https://github.com/transitive-bullshit/chatgpt-api/issues/96#issuecomment-1350275343)
I am currently working on upgrading the login method for the extension to include an option to login using email and password, which will hopefully help solve this, will update you all then. In the meantime, if anyone learns something new about this, feel free to post it here!
Update:
It seems like using Chrome to obtain the tokens is what is causing (most of?) these issues (see this, this). So if you have 403 Error despite following the instructions, try using a browser other than Chrome!
I will update the README to include this info.
It looks like this problem is not limited to this project, but also to some other ones using chatgpt-api, probably caused by agressive CloudFlare protection. In my own testing, even when I tried to login to my account in Chrome right after using it inside Edge, I got a 403 error inside the web version. After I waited for several minutes and tried again, it disappeard, but this shows that the problem is not just with the javascript API.
The browser that you use for getting the tokens might influence the chance to get 403, especially Chrome, so maybe try from another one (transitive-bullshit/chatgpt-api#107 (comment))
There might also be some account or IP flagging going on either by OpenAI or CloudFlare that increases the possibility of getting 403 especially if doing lots of requests often (transitive-bullshit/chatgpt-api#96 (comment))
I am currently working on upgrading the login method for the extension to include an option to login using email and password, which will hopefully help solve this, will update you all then. In the meantime, if anyone learns something new about this, feel free to post it here!
I downloaded just for this the Opera GX Browser and now it works. The Session-token seems to be the same but what was defnitly diffrent is the "cf_clearance" token and slightly the "userAgent" but it just looks like a diffrent Version of Chrome
Great, then it seems like using Chrome to obtain the tokens is what is causing (most of?) these issues.
So if you have 403 Error despite following the instructions, try using a browser other than Chrome!
I will update the README to include this info.
I can confirm that the token generated with Opera GX works with my VS Code (not yet with gitpod but I will get there :) )
Had no success with neither Microsoft Edge, nor Opera GX, getting 403s. Maybe this has something to do with VS Code running under WSL2 that messes with IP addressing, maybe not.
@kirsanium Doubtful. Same issue here and I'm running on MacOS.
Is it possible that this might have something to do with an Ad Blocker or being behind a PiHole setup?
This the new error that I'm getting [ERROR] Error: ChatGPT failed to refresh auth token. TypeError: Cannot convert argument to a ByteString because the character at index 112 has a value of 65279 which is greater than 255. I tryed every browser and they all failed and I disabled my Adblock and it didn't make any difference.
Still no go with AdGaurd disabled.
Not working for me even using Opera GX :( It looks like there is a new version of https://github.com/transitive-bullshit/chatgpt-api that uses a browser-based authentication method, I wonder if that might work here?