realcoloride / node_characterai

Unofficial Character AI wrapper for node.
https://beta.character.ai/
346 stars 71 forks source link

Authentication methods changed #146

Closed realcoloride closed 8 months ago

realcoloride commented 8 months ago

Hello,

For the second time, it seems like characterai has switched to a new way of authentication.

realcoloride commented 8 months ago

From my search, it seems like atleast for google accounts, there is an id tokenand key associated with a token from the new endpoint of dj-rest-auth/google_idp/. image

This produces a session token. image

This is the endpoint in question. image

For easier development purposes, I might have to switch to using the session token only and rework the README.md. image

I will keep you updated.

realcoloride commented 8 months ago

Hello again, image

Changing to char_token seems to be a viable solution. I will push a fix along with the readme.md tutorial soon.

realcoloride commented 8 months ago

I added a warning message if the token is not as the same size of char_tokens (40). image

realcoloride commented 8 months ago

I've updated the code for mobile token gathering. image

realcoloride commented 8 months ago

Relevant commits: https://github.com/realcoloride/node_characterai/commit/7cb8e59a241049edbb7d0183c31feeed5d1b7f37 and https://github.com/realcoloride/node_characterai/commit/46db79ec79e58e36e326130060fc512dae0abfb5.

Experimental version 1.2.5 was pushed, please let me know how it goes for you all.

Asphyxiav2 commented 8 months ago

Screenshot_20240205-233206 No id token

realcoloride commented 8 months ago

Hello, please read the entire issue. Id tokens and access tokens have been replaced with session tokens. See README.md.

azureknight63 commented 8 months ago

Thanks for the update. Your changes seem to be effective. For the readme update, it seems that the access token is now under Local Storage > char_token.value as you described. The ID token is under Local Storage > uuid.

It also looks like char_token has a 1-month TTL property. It's hard to suggest a feature if character.ai is going to change authentication methods this frequently, but if it stabilizes then I would recommend including utility for updating the char_token.

Cheers.

realcoloride commented 8 months ago

I seem to have also detected that the newer chat interface uses a websocket whilst the old interface uses good old requests. Might be interesting to open an issue related to it.

ameshkin commented 1 day ago

I believe things may have changed again. I can't seem to find the right tokens in the local storage.

realcoloride commented 1 day ago

Hello there, open up dev tools, try going in the "Network" tab when opening dev tools, and filter by Fetch/XHR.

image

Then, open up any conversation. You'll see something like this.

image

Click in one of the requests, and look for the Authorization key. image

Then, look for the Authorization key. Whatever comes after "Token " is what you are looking for.

Cheers