agentic
agentic copied to clipboard
Check everything and still 403
Hi, @transitive-bullshit
I have check every step you say and still 403
In my case, I run robot on a server. This server also run a http proxy. On my local PC, I use Chrome to access ChatGpt webapp with using proxy running on my server. Then I put session and cf_token onto server and use this lib. Below is my code
chatGpt: new ChatGPTAPI({
//fresh token copy form Chrome
sessionToken: account.session_token,
clearanceToken: account.clearance_token,
// copy from chrom console
userAgent: "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"
}),
But, I still get 403
-
Make sure you're using Node.js >= 18 sure, node version is v19.2.0
-
Make sure you're using the latest version of this package sure , "chatgpt": "^2.3.1",
-
Make sure your IP address and user agent match exactly the browser that's being used to generate the CF token and session tokens sure, because I use a http proxy to ensure browser and robot in same IP address
-
This means that for most cases, you can't use a proxy or VPN to connect to the API
-
Make sure you're using your local install of Chrome and not the default puppeteer executable (which Cloudflare detects) sure, a normal Chrome I daily use
-
Make sure you're not using the account in a browser window at the same time (since it can invalidate your bot's credentials) sure, I close browser tab before robot start
+1 on this
@slovx2 can you try using everything locally? It's entirely possible that the proxy you're using is blocklisted by Cloudflare. It's also possible that your account has been blocklisted.
If you can get the bot running entirely locally without proxies, then that will rule a lot of things out.
Only once you have everything running fine locally should you try to move things to a server and/or introduce proxies.
Same problem here, not using any proxies:
UserAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Using chatAPI through https://github.com/gencay/vscode-chatgpt
@transitive-bullshit It's hard to run entirely locally without proxies because OpenAI services are not available in our country, and I haven‘t install node or npm on my local PC. So I try in a easy way:
-
I login (another account) chatgpt with http_proxy (sorry, but I can't login wihtout proxies)
-
Detete cl_token
-
Refresh website without proxies (I can use chatgpt normally on web)
-
Export Request from console:
-
Paste to Terminal and run --- still got 403
-
Import to Postman and run --- still got 403
I think I will get 403 also if I use this lib locally
What different between Browser/this lib and Terminal/Postman ?
@transitive-bullshit It's hard to run entirely locally without proxies because OpenAI services are not available in our country, and I haven‘t install node or npm on my local PC. So I try in a easy way:
- I login (another account) chatgpt with http_proxy (sorry, but I can't login wihtout proxies)
- Detete cl_token
- Refresh website without proxies (I can use chatgpt normally on web)
- Export Request from console:
![]()
- Paste to Terminal and run --- still got 403
- Import to Postman and run --- still got 403
I think I will get 403 also if I use this lib locally
What different between Browser/this lib and Terminal/Postman ?
I had exactly the same situation in which I copied the whole request to postman but still got 403 error. I'm really confused about how Cloudflare can tell different requests for the same headers.
maybe some random token return follow a response and use in next request?
@transitive-bullshit It's hard to run entirely locally without proxies because OpenAI services are not available in our country, and I haven‘t install node or npm on my local PC. So I try in a easy way:
- I login (another account) chatgpt with http_proxy (sorry, but I can't login wihtout proxies)
- Detete cl_token
- Refresh website without proxies (I can use chatgpt normally on web)
- Export Request from console:
![]()
- Paste to Terminal and run --- still got 403
- Import to Postman and run --- still got 403
I think I will get 403 also if I use this lib locally What different between Browser/this lib and Terminal/Postman ?
I had exactly the same situation in which I copied the whole request to postman but still got 403 error. I'm really confused about how Cloudflare can tell different requests for the same headers.
Same problem here, not using any proxies:
UserAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Using chatAPI through gencay/vscode-chatgpt
@Noppey please create a separate issue for your case so we can focus on diagnosing one person at a time. Please also search the existing issues for advice as I've already responded to your question re:vscode elsewhere. In short, get the package working yourself locally first, and only then try using a separate package.
@slovx2 @ikechan8370 is your local curl
request using the same IP as the browser version? @slovx2 it sounds like you're trying to use auth credentials generated from one IP on another IP, which will definitely be blocked by Cloudflare.
Sorry if I'm not following; I'd really love to help you figure out what's going on so I can improve the docs for other users as well.
@transitive-bullshit It's hard to run entirely locally without proxies because OpenAI services are not available in our country, and I haven‘t install node or npm on my local PC. So I try in a easy way:
- I login (another account) chatgpt with http_proxy (sorry, but I can't login wihtout proxies)
- Detete cl_token
- Refresh website without proxies (I can use chatgpt normally on web)
- Export Request from console:
![]()
- Paste to Terminal and run --- still got 403
- Import to Postman and run --- still got 403
I think I will get 403 also if I use this lib locally
What different between Browser/this lib and Terminal/Postman ?
Hello, You can try to comment the following code to make it invalid and then debug it. I guess it may be because api.ensureAuth()
issued a wrong request during execution, which caused the cf authentication to fail.
// const api = new ChatGPTAPI({ ...openAIAuth });
// await api.ensureAuth();
// send a message and wait for the response
// const response = await api.sendMessage(
// 'Write a python version of bubble sort.'
// );
// console.log('response', response);
Another possibility is that cf uses monster-in-the-middle to judge whether you are chrome or postman
@transitive-bullshit yes, my curl use the same IP as the browser. As I explained befor, I can't login without proxies. But I can use chatgpt web normally without proxies after login What make me confuse is that way a same request work fine on browser but error on curl/postman. (same IP and without proxies)
And my server's OS have no Desktop system like Ubuntu. I think there is some wrong among my operations and I gave up this way. I'm trying to install Ubuntu on my server so that I can do everything on server. Or I should wait for support that auto passing captcha .
@mtrucc Can my phenomenon be reproduced on your device?
https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.4.0 introduces a now fully browser-based solution, ChatGPTAPIBrowser
that should resolve a lot of people's 403 / 429 errors — unless your account of IP address has been banned.
Thanks, and sorry for all the headaches that Cloudflare has caused.
@transitive-bullshit That's great. But on version 2.4.2, it seems that chatgpt module does not export type ChatGPTAPIBrowser, and ChatGPTAPIBrowser miss some method like 'getConversation()'
@slovx2 yes; I'm currently working on adding conversation tracking support to the browser version.
@transitive-bullshit thank you, for a great job
@slovx2 https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.5.0 adds support for conversations to the browser version 🔥
You have to use the onConversationResponse
parameter to get the conversationId
and messageId
.
@transitive-bullshit Is't able to use a headless browser now?
@slovx2 https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.5.0 adds support for conversations to the browser version 🔥
You have to use the
onConversationResponse
parameter to get theconversationId
andmessageId
.
Hello, thanks for your update and it finally works now. But I want to know if I could manually control browser parameters. Because in my usage scenario, as a plug-in, it will call init every time to create a new chrome window. I hope I can pass in the browser I created, just like the getOpenAIAuth function.
I use a headless browser and block here:
Should I click it manually?
@slovx2 yes; you have to manually bypass captchas.
v3.0.0 now automatically bypasses captchas as well if you set the right env vars.
Closing as outdated. Please open a new issue if you're still experiencing problems. Thanks! 🙏