agentic
agentic copied to clipboard
error 403
Cloned this repo and tried demo.ts . getting 403 error.
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 , cloned repor
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, i am testing in locally only
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
Getting below error
ChatGPTError: ChatGPT failed to refresh auth token. Error: 403 Forbidden at ChatGPTAPI.refreshAccessToken (/Users/suhail/Downloads/chatgpt-api-main/src/chatgpt-api.ts:406:21) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at ChatGPTAPI.ensureAuth (/Users/suhail/Downloads/chatgpt-api-main/src/chatgpt-api.ts:320:12) at main (/Users/suhail/Downloads/chatgpt-api-main/demos/demo-conversation.ts:27:3) { response: Response { [Symbol(realm)]: null, [Symbol(state)]: { aborted: false, rangeRequested: false, timingAllowPassed: true, requestIncludesCredentials: true, type: 'default', status: 403, timingInfo: [Object], cacheState: '', statusText: 'Forbidden', headersList: [HeadersList], urlList: [Array], body: [Object] }, [Symbol(headers)]: HeadersList { [Symbol(headers map)]: [Map], [Symbol(headers map sorted)]: null } }, statusCode: 403, statusText: 'Forbidden', originalError: ChatGPTError: 403 Forbidden at (/Users/suhail/Downloads/chatgpt-api-main/src/chatgpt-api.ts:358:25) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at ChatGPTAPI.refreshAccessToken (/Users/suhail/Downloads/chatgpt-api-main/src/chatgpt-api.ts:352:19) at ChatGPTAPI.ensureAuth (/Users/suhail/Downloads/chatgpt-api-main/src/chatgpt-api.ts:320:12) at main (/Users/suhail/Downloads/chatgpt-api-main/demos/demo-conversation.ts:27:3) { response: Response { [Symbol(realm)]: null, [Symbol(state)]: [Object], [Symbol(headers)]: [HeadersList] }, statusCode: 403, statusText: 'Forbidden' } }
Tried console getting cookies. It is producing the cookies. Exiting with this error. Chat gpt is working in chrome.
Same here
Same here
+1
@suhail-ak-2 thanks for opening an issue. Can you include the command you're executing and all console output to help debug? Is getOpenAIAuth
returning successfully with all auth credentials, or are you only getting this afterwards?
I'm going to create an issue template to help people give more info which should make it easier to determine what might be going on.
@Noppey @mtrucc @vbonluk saming +1 or same here is not helpful and will not help me help you. This is why github has the thumbs up feature on issues. If you're experiencing a similar issue, please create your own, separate issue with as much detail as possible.
Yes i am getting the cookies from the getOpenAIAuth
.
Using the command npx tsx demos/demo-conversation.ts
to run the code.
@transitive-bullshit
it is throwing this error only ChatGPTError: ChatGPT failed to refresh auth token. Error: 403 Forbidden
Cookies
authInfo: {
userAgent: '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',
clearanceToken: 'JkFeOqxJhWHmHWzSq815moYJ1464XS1Lsd4HkkldTI0-1671074784-0-1-fcff497e.ac4f6c79.8d786573-160',
sessionToken: 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..7iEENqZLmzpvxaPk.SLWNwuATs29W01KCR-gn9hUmQUeyasEwnf7xCOgsQUftCa0EO7PORqKk_ZvFPQhxDc3nQsnnZOvFL3w3NQ2a25TgZJpM2eVbSxhvSmVJ4bKooZ7rphdeB0Cy166tXaZImJ-s7ILfuIyg4qaxMDo5B_lFzdtUaTjDIubqOe-3SR3lGCWZCCrxlrJNG2BQA27Okpj1HAPC0nO_cpq7g7xLk_7paRuZUHLI7M9ckSVQletqXFSZUM8c2LeP3TIIpwgLRG4wVns2VvqBGDGllngxt8rk1huvZkM2025tmFI56UZc_mDZ1s6iIFC8OkZMk7T1iLiJ3d56gdcOq_SE9fkoffZ_FjiWrOY06kJz_V_xPlfgCSvy_PeA9ZSn64KbNdX6UbmG9JtRonBP1pv0i-EtNH_LuWhDEzDb7sHWyTMp1fw3K-sFaBfEB05QbIhOrbDh8b5aoTXSpgadHrT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vorMYD2vFqAS4KJHSYyYPZAXnnLjT3p_-EHIiegiDxCJ4oS5TooTnmsP0M3yOl5XwpOlq1XKd_3dUKZmYZ8h0DP7kztCh_LF9a8k59p_T34_EVVqY6KQ7pTjQaMnCisWAZvjMsTvn26NUNtT1Hasz5YENUnT786TArfAfxPQeZRSfVkoNiZNZitH2dtABZZLfhusSrOY37BFpi7cUCOr7uAvf5dze2xu2Ww_6qu8axgnvRet_IbA5RjkHmFR1aujO8fZun0k7PKH5QgArNckcioD0i9Iu9SLla6jmzMe4onHkMHnkXXBRvxiZEvUpg2MV1lLe93ro4_jJUJREDiK3cPdr2vXuYKcT38XtYA9Mrio5hNwqSoCaaEZkFxu8Vzjwm-9K8sQ0MsUuIQeLt7uFVTZOCswlWwgkHfV-CoLGe7ToQLP_t7Hw2FYoYBUdNXPqXVNOaSvoTYQg6TYWyRMPykPc18R-Q3p3hScaSwhdJWbDRdf1EfCtGLRxl43Xl70TgH_nTzOPAQpqv2Bmyn2UT_W8Dvak4HqGKglmnQIv9SvL1U2twD7cfiSie8NBkh9e_ki-qUYNKg2wh19I678r_Fa5iJG-rMdQwEgd3rHyiGwcGyFkOryOMQBzl8nVdH9SyGCfoEZgtgBBHJ9tEhzqjU9w2QkNMm9_yaAaKK3IzUgg5k4A2x-XZwHoC9BTriza1UtfDVl7ucQRzYOMiLPR54nea8w7vvANsXrDHmrcIMtHHKT1rjKrgQ7qhIZN9LMW4kv8MNLvuy7KUgaiWUD_o7fiWvXKGYJwNVQCjFPbZPw.H6pVG4VsgWMSqtZvsDzlhg',
cookies: {
'__Secure-next-auth.callback-url': [Object],
'__Host-next-auth.csrf-token': [Object],
cf_clearance: [Object],
cf_chl_2: [Object],
'__Secure-next-auth.session-token': [Object],
__cf_bm: [Object],
cf_chl_rc_m: [Object]
}
}
}
+1
npx tsx demos/demo.ts
(node:65964) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use node --trace-warnings ...
to show where the warning was created)
/Users/qiangjiang/Desktop/chatgpt-api/src/chatgpt-api.ts:406
const error = new types.ChatGPTError(
^
Error: ChatGPT failed to refresh auth token. Error: 403 Forbidden
at ChatGPTAPI.refreshAccessToken (/Users/qiangjiang/Desktop/chatgpt-api/src/chatgpt-api.ts:406:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at ChatGPTAPI.ensureAuth (/Users/qiangjiang/Desktop/chatgpt-api/src/chatgpt-api.ts:320:12)
at main (/Users/qiangjiang/Desktop/chatgpt-api/demos/demo.ts:25:3) {
response: Response {
[Symbol(realm)]: null,
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: 'default',
status: 403,
timingInfo: [Object],
cacheState: '',
statusText: 'Forbidden',
headersList: [HeadersList],
urlList: [Array],
body: [Object]
},
[Symbol(headers)]: HeadersList {
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
}
},
statusCode: 403,
statusText: 'Forbidden',
originalError: /Users/qiangjiang/Desktop/chatgpt-api/src/chatgpt-api.ts:358
const error = new types.ChatGPTError(${r.status} ${r.statusText}
)
^
Error: 403 Forbidden
at
ChatGPT now automatically invalidate your sessions if there's no activity for a long time. You need to re-login to continue use.
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.
Please give the new version a try and let me know how it goes in a new issue.
Thanks, and sorry for all the headaches that Cloudflare has caused.