> As of December 11, 2022 ~2pm CST, OpenAI has enabled additional Cloudflare restrictions that are currently preventing us from refreshing access tokens. This is affecting _all_ ChatGPT API wrappers at the moment, including the Python ones. See [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96) for an ongoing discussion until I release a viable workaround.
Today, OpenAI added additional Cloudflare protections that make it more difficult to access the unofficial API. _This is affecting all ChatGPT API wrappers at the moment_, including the Python ones. See [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96).
**As a temporary workaround**, make sure you're using the latest version of this package and Node.js >= 18:
1. Log into https://chat.openai.com/chat and copy a fresh session token (same instructions as below).
2. Copy the value of the `cf_clearance` cookie and store it in a `CLEARANCE_TOKEN` environment variable in addition to your `SESSION_TOKEN`.
3. Copy your browser's `user-agent` header from any request in your browser's network tab.
4. Use both tokens when creating the API wrapper:
```ts
constapi=newChatGPTApI({
sessionToken:process.env.SESSION_TOKEN,
clearanceToken:process.env.CLEARANCE_TOKEN,
userAgent:''// replace to match your real browser's user agent
})
awaitapi.ensureAuth()
```
Restrictions on this method:
- Cloudflare `cf_clearance`**tokens expire after 2 hours**, so right now you manually have to log in and extract it by hand every so often
- Your `user-agent` and `IP address`**must match** from the real browser window you logged into to the one you're using for `ChatGPTAPI`.
- This means that you currently can't log in with your laptop and then run the bot on a server somewhere.
- You must use `node >= 18`. I'm using `v19.2.0` in my testing, but for some reason, all `fetch` requests using `v16` and `v17` fail at the moment (these use `undici` under the hood, whereas Node.js v18 and above use a built-in `fetch` based on `undici`).
We're working hard in [this issue](https://github.com/transitive-bullshit/chatgpt-api/issues/96) to make this process easier and more automated.