EdgeGPT icon indicating copy to clipboard operation
EdgeGPT copied to clipboard

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

Open DrowskoytayhulGuider opened this issue 1 year ago • 18 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

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

DrowskoytayhulGuider avatar Jun 21 '23 15:06 DrowskoytayhulGuider

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

acheong08 avatar Jun 21 '23 15:06 acheong08

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.

DrowskoytayhulGuider avatar Jun 22 '23 02:06 DrowskoytayhulGuider

Where does it redirect to?

acheong08 avatar Jun 22 '23 03:06 acheong08

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

Nu11Const avatar Jun 22 '23 03:06 Nu11Const

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.

Nu11Const avatar Jun 22 '23 03:06 Nu11Const

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

acheong08 avatar Jun 22 '23 03:06 acheong08

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

Nu11Const avatar Jun 22 '23 04:06 Nu11Const

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

acheong08 avatar Jun 22 '23 04:06 acheong08

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

Nu11Const avatar Jun 22 '23 04:06 Nu11Const

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

acheong08 avatar Jun 22 '23 04:06 acheong08

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

not edgeservices?

acheong08 avatar Jun 22 '23 04:06 acheong08

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 avatar Jun 22 '23 04:06 Nu11Const

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

not edgeservices?

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

Nu11Const avatar Jun 22 '23 04:06 Nu11Const

BingImageCreator need a full site proxy

Nu11Const avatar Jun 22 '23 04:06 Nu11Const

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

acheong08 avatar Jun 22 '23 04:06 acheong08

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.

Nu11Const avatar Jun 22 '23 04:06 Nu11Const

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

DrowskoytayhulGuider avatar Jul 09 '23 12:07 DrowskoytayhulGuider

Snipaste_2023-07-09_20-41-20

DrowskoytayhulGuider avatar Jul 09 '23 12:07 DrowskoytayhulGuider