acheong08 / ChatGPTProxy

Simple Cloudflare bypass for ChatGPT
The Unlicense
1.33k stars 326 forks source link

Why do I keep returning 403? #97

Open hackerhaiJu opened 1 year ago

hackerhaiJu commented 1 year ago

Big Boss, I would like to ask why I use java to initiate a request through tls, set a proxy, copy Authorization and cookie through the page, and set the same as the header of the page initiating a request. Why do I always return 403? Can you teach me? I want to write a java version

public static void main() {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
            URL url = new URL(CONVERSATION);
            HttpsURLConnection httpURLConnection = (HttpsURLConnection) url.openConnection(proxy);
            httpURLConnection.setSSLSocketFactory(getTLSFactory());
            httpURLConnection.setRequestMethod("GET");
            httpURLConnection.setDoInput(true);
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setRequestProperty("Accept", "text/event-stream");
            httpURLConnection.setRequestProperty("Origin", "https://chat.openai.com/chat");
            httpURLConnection.setRequestProperty("Authorization", Authorization);
            httpURLConnection.setRequestProperty("Content-Type", "application/json");
            httpURLConnection.setRequestProperty("Referer", "https://chat.openai.com/c/e63118ea-2046-42f7-904b-9c923a874b67");
            httpURLConnection.setRequestProperty("Cookie", cookie);
            httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:114.0) Gecko/20100101 Firefox/114.0");
            httpURLConnection.setRequestProperty("Sec-Ch-Ua", "Microsoft Edge\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117");
            httpURLConnection.setRequestProperty("Sec-Ch-Ua-Mobile", "?0");
            httpURLConnection.setRequestProperty("Sec-Ch-Ua-Platform", "Windows");
            httpURLConnection.setRequestProperty("Sec-Fetch-Dest", "empty");
            httpURLConnection.setRequestProperty("Sec-Fetch-Mode", "cors");
            httpURLConnection.setRequestProperty("Sec-Fetch-Site", "same-origin");
}
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 403 for URL: https://chat.openai.com/backend-api/conversation
    at demo.chatgpt.ChatGptTest.main(ChatGptTest.java:103)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://chat.openai.com/backend-api/conversation
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
    at demo.chatgpt.ChatGptTest.main(ChatGptTest.java:93)