PyCharacterAI icon indicating copy to clipboard operation
PyCharacterAI copied to clipboard

AuthenticationError despite already authenticating the user

Open ChimiChamo opened this issue 4 months ago • 1 comments

I'm using the simple chatting example directly for this, but whenever I run it it provides this error despite stating that it has already authenticated me and even got the username:

`Authenticated as @euylis Traceback (most recent call last): File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\requester.py", line 143, in __ws_connect_async self.__ws = await self.__requester_session.ws_connect( File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\curl_cffi\requests\session.py", line 932, in ws_connect await self.loop.run_in_executor(None, curl.perform) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\curl_cffi\curl.py", line 365, in perform self._check_error(ret, "perform") File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\curl_cffi\curl.py", line 187, in _check_error raise error curl_cffi.curl.CurlError: Failed to perform, curl: (22) Refused WebSockets upgrade: 403. See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\coachGPT\character.py", line 35, in asyncio.run(main()) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "c:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\coachGPT\character.py", line 16, in main chat, greeting_message = await client.chat.create_chat(character_id) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\methods\chat.py", line 316, in create_chat async for raw_response in request: File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\requester.py", line 233, in ws_send_and_receive_async await self.__ws_send_async(message=message, token=token) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\requester.py", line 168, in __ws_send_async await self.__ws_ensure_connection(token=token) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\requester.py", line 159, in __ws_ensure_connection await self.__ws_connect_async(token=token) File "C:\Users\Nick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyCharacterAI\requester.py", line 152, in __ws_connect_async raise AuthenticationError("maybe your token is invalid?") PyCharacterAI.exceptions.AuthenticationError: maybe your token is invalid?`

ChimiChamo avatar Aug 18 '25 22:08 ChimiChamo

having the same issue here! this happens during a conversation, not at the initialization (or authentication) step.

willystumblr avatar Oct 13 '25 04:10 willystumblr