docs: update current workaround status

pull/101/head
Travis Fischer 2022-12-11 19:52:50 -06:00
rodzic b4771a01e6
commit 3d442ae92f
1 zmienionych plików z 48 dodań i 12 usunięć

Wyświetl plik

@ -1,5 +1,40 @@
> **Note**
> 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.
# Update December 11, 2022
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
const api = new ChatGPTApI({
sessionToken: process.env.SESSION_TOKEN,
clearanceToken: process.env.CLEARANCE_TOKEN,
userAgent: '' // replace to match your real browser's user agent
})
await api.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.
Cheers,
Travis
---
<p align="center">
<img alt="Example usage" src="/media/demo.gif">
@ -11,16 +46,17 @@
[![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/chatgpt) [![Build Status](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml/badge.svg)](https://github.com/transitive-bullshit/chatgpt-api/actions/workflows/test.yml) [![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/transitive-bullshit/chatgpt-api/blob/main/license) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)
- [Intro](#intro)
- [Install](#install)
- [Usage](#usage)
- [Docs](#docs)
- [Demos](#demos)
- [Session Tokens](#session-tokens)
- [Projects](#projects)
- [Compatibility](#compatibility)
- [Credits](#credits)
- [License](#license)
- [Update December 11, 2022](#update-december-11-2022)
- [Intro](#intro)
- [Install](#install)
- [Usage](#usage)
- [Docs](#docs)
- [Demos](#demos)
- [Session Tokens](#session-tokens)
- [Projects](#projects)
- [Compatibility](#compatibility)
- [Credits](#credits)
- [License](#license)
## Intro