acheong08 / EdgeGPT

Reverse engineered API of Microsoft's Bing Chat AI
The Unlicense
8.07k stars 909 forks source link

[Bug]: 'Exception: Authentication failed' with a Status code: 302 #569

Open DrowskoytayhulGuider opened 1 year ago

DrowskoytayhulGuider commented 1 year ago

Is there an existing issue for this?

What happened?

ran "python -m EdgeGPT.EdgeGPT --cookie-file ./cookies.json" and got the Exception: EdgeGPT - A demo of reverse engineering the Bing GPT chatbot Repo: github.com/acheong08/EdgeGPT By: Antonio Cheong

    !help for help

    Type !exit to exit

Initializing... Enter alt+enter or escape+enter to send a message Status code: 302

Object moved

Object moved to here.

https://edgeservices.bing.com/edgesvc/turing/conversation/create Traceback (most recent call last): File "D:\program files (x86)\python\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\program files (x86)\python\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\EdgeGPT.py", line 218, in main() File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\main.py", line 244, in main asyncio.run(async_main(args)) File "D:\program files (x86)\python\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "D:\program files (x86)\python\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\main.py", line 79, in async_main bot = await Chatbot.create(proxy=args.proxy, cookies=cookies) File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\EdgeGPT.py", line 42, in create await Conversation.create(self.proxy, cookies=cookies), File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\conversation.py", line 111, in create raise Exception("Authentication failed") Exception: Authentication failed

Steps to reproduce the problem

  1. run "pip install EdgeGPT==0.11.4" to get EdgeGPT and get the cookie following the method as you said.
  2. write "python -m EdgeGPT.EdgeGPT --cookie-file ./cookies.json" in cmd.
  3. press enter.
  4. go wrong.

What should have happened?

Chat with new Bing normally.

Version where the problem happens

EdgeGPT 0.11.4

What Python version are you running this with?

python 3.9.0

What is your operating system ?

Windows

Command Line Arguments

Console logs

EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit

Initializing...
Enter `alt+enter` or `escape+enter` to send a message
Status code: 302
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://cn.bing.com/edgesvc/turing/conversation/create">here</a>.</h2>
</body></html>

https://edgeservices.bing.com/edgesvc/turing/conversation/create
Traceback (most recent call last):
  File "D:\program files (x86)\python\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\program files (x86)\python\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\EdgeGPT.py", line 218, in <module>
    main()
  File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\main.py", line 244, in main
    asyncio.run(async_main(args))
  File "D:\program files (x86)\python\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\program files (x86)\python\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\main.py", line 79, in async_main
    bot = await Chatbot.create(proxy=args.proxy, cookies=cookies)
  File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\EdgeGPT.py", line 42, in create
    await Conversation.create(self.proxy, cookies=cookies),
  File "D:\program files (x86)\python\lib\site-packages\EdgeGPT\conversation.py", line 111, in create
    raise Exception("Authentication failed")
Exception: Authentication failed

Additional information

No response

acheong08 commented 1 year ago

If that doesn't work, do export BING_PROXY_URL="https://cn.bing.com/edgesvc/turing/conversation/create"

DrowskoytayhulGuider commented 1 year ago

If that doesn't work, do export BING_PROXY_URL="https://cn.bing.com/edgesvc/turing/conversation/create"

I have set it as an environment variable. I got another status code:301. The same exception still exists.

acheong08 commented 1 year ago

Where does it redirect to?

Nu11Const commented 1 year ago

Hey,@acheong08,https://cn.bing.com/edgesvc/turing/conversation/create is doesn't work.If you can make a proxy for EdgeGPT,BingImageCreator?

Nu11Const commented 1 year ago

Fix then:

     EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit

Initializing...
Enter `alt+enter` or `escape+enter` to send a message
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/EdgeGPT/EdgeGPT.py", line 218, in <module>
    main()
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/EdgeGPT/main.py", line 244, in main
    asyncio.run(async_main(args))
  File "/data/data/com.termux/files/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/EdgeGPT/main.py", line 79, in async_main
    bot = await Chatbot.create(proxy=args.proxy, cookies=cookies)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/EdgeGPT/EdgeGPT.py", line 42, in create
    await Conversation.create(self.proxy, cookies=cookies),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/EdgeGPT/conversation.py", line 103, in create
    response = await client.get(
               ^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/httpx/_client.py", line 1675, in _send_handling_redirects
    raise TooManyRedirects(
httpx.TooManyRedirects: Exceeded maximum allowed redirects.
acheong08 commented 1 year ago

Looks like a recursive redirect. Could it be because of the IP spoofing?

Nu11Const commented 1 year ago

Make a public proxy without cloudflare CDN,Try another CDN.

acheong08 commented 1 year ago

Which CDN is free and accessible for China? I tried gcore before but it didn't work

Nu11Const commented 1 year ago

Make a full reverse proxy https://www.bing.com

acheong08 commented 1 year ago

btw https://github.com/acheong08/EdgeGPT/commit/9b32a3292903575c8ea5c26ed86289d4ad9cfa4c might help with the redirect.

acheong08 commented 1 year ago

Make a full reverse proxy https://www.bing.com

not edgeservices?

Nu11Const commented 1 year ago

Which CDN is free and accessible for China? I tried gcore before but it didn't work

Do you know the Chinese CDN services? What about the Aliyun or the Tencent cloud? But it not free.

Nu11Const commented 1 year ago

Make a full reverse proxy https://www.bing.com

not edgeservices?

Yes,not edgeservices,It can be use in EdgeGPT and the BingImageCreator.

Nu11Const commented 1 year ago

BingImageCreator need a full site proxy

acheong08 commented 1 year ago

Can China access repl.it, vercel, or cloudflare workers? I ran out of credit for my US server recently

Nu11Const commented 1 year ago

Can China access repl.it, vercel, or cloudflare workers? I ran out of credit for my US server recently

repl.it can work,vercel.app domain can't access,but with a custom domain can work.worker.dev domain can't access,but with a custom domain can work.

DrowskoytayhulGuider commented 1 year ago

Hey, is there any good solution for "httpx.TooManyRedirects: Exceeded maximum allowed redirects."? I aways meet this problem.

DrowskoytayhulGuider commented 1 year ago

Snipaste_2023-07-09_20-41-20