Authentication token is invalid no matter the token on 1.x branch
Although I'm using the second version now, I'm still interested. When using the first version, at some point it just stopped working, literally, every time a request is attempted, the error "Authentication token is invalid" appears. Everything used to work with my token, the problem appeared just a couple of weeks ago.
Hello,
Thank you for letting me know. Did you use your HTTP_AUTHORIZATION token, or something else?
Cheers
On Wed, Apr 9, 2025 at 8:56 PM IceVladimir @.***> wrote:
Although I'm using the second version now, I'm still interested. When using the first version, at some point it just stopped working, literally, every time a request is attempted, the error "Authentication token is invalid" appears. Everything used to work with my token, the problem appeared just a couple of weeks ago.
— Reply to this email directly, view it on GitHub https://github.com/realcoloride/node_characterai/issues/197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ4WO5ITEF6Z7SPO3J3RHIT2YVUMZAVCNFSM6AAAAAB2ZXTZIOVHI2DSMVQWIX3LMV43ASLTON2WKOZSHE4DGNRTHAYTEOI . You are receiving this because you are subscribed to this thread.Message ID: @.***> IceVladimir created an issue (realcoloride/node_characterai#197) https://github.com/realcoloride/node_characterai/issues/197
Although I'm using the second version now, I'm still interested. When using the first version, at some point it just stopped working, literally, every time a request is attempted, the error "Authentication token is invalid" appears. Everything used to work with my token, the problem appeared just a couple of weeks ago.
— Reply to this email directly, view it on GitHub https://github.com/realcoloride/node_characterai/issues/197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ4WO5ITEF6Z7SPO3J3RHIT2YVUMZAVCNFSM6AAAAAB2ZXTZIOVHI2DSMVQWIX3LMV43ASLTON2WKOZSHE4DGNRTHAYTEOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I am also having the same problem and the token is fine.
Hello there,
Upon testing on my end (beta branch), I cannot seem to replicate the issue. If you however mean the old legacy 1.x branch, let me know.
What does your authorization token look like? What is the error that you both get? Could you send a piece of your code; Please censor the token however.
Cheers
I am also getting this error on the 1.x version, Error: Authentication token is invalid. I have the actual token and characterId here, I have checked and they are the same. This was working previously and I have also tried with some other characters.
const CharacterAI = require("node_characterai");
const characterAI = new CharacterAI(); characterAI.authenticateWithToken("token here"); const characterId = "id here";
Hello,
I'll investigate the issue on the 1.x branch and try to replicate the issue.
Cheers
On Thu, Apr 17, 2025, 4:23 AM thunderslam12 @.***> wrote:
I am also getting this error on the 1.x version, Error: Authentication token is invalid. I have the actual token and characterId here, I have checked and they are the same. This was working previously and I have also tried with some other characters.
const CharacterAI = require("node_characterai");
const characterAI = new CharacterAI(); characterAI.authenticateWithToken("token here"); const characterId = "id here";
— Reply to this email directly, view it on GitHub https://github.com/realcoloride/node_characterai/issues/197#issuecomment-2811565828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ4WO5ONSY3WVODVKUP7HFT2Z4GDLAVCNFSM6AAAAAB2ZXTZIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJRGU3DKOBSHA . You are receiving this because you commented.Message ID: @.***> thunderslam12 left a comment (realcoloride/node_characterai#197) https://github.com/realcoloride/node_characterai/issues/197#issuecomment-2811565828
I am also getting this error on the 1.x version, Error: Authentication token is invalid. I have the actual token and characterId here, I have checked and they are the same. This was working previously and I have also tried with some other characters.
const CharacterAI = require("node_characterai");
const characterAI = new CharacterAI(); characterAI.authenticateWithToken("token here"); const characterId = "id here";
— Reply to this email directly, view it on GitHub https://github.com/realcoloride/node_characterai/issues/197#issuecomment-2811565828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ4WO5ONSY3WVODVKUP7HFT2Z4GDLAVCNFSM6AAAAAB2ZXTZIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJRGU3DKOBSHA . You are receiving this because you commented.Message ID: @.***>
I have the same issue on 1.x branch, token stopped randomly working about two weeks ago. To make sure it wasn't just that my token expired, I grabbed a new one from the Request Headers, but it still gives the same error.
Hello, I've investigated the problem and have found the issue.
The problem resides in the line https://github.com/realcoloride/node_characterai/blob/2dc8632f58beba2cccd64ea5303b433c9985b146/client.js#L218
The domain currently returns 405 (Method Not Allowed) no matter the request if the token is valid. However on an invalid token, it returns 401, which should be the expected outcome. This comes with deprecating the current endpoint too.
Instead, I will replace it by https://beta.character.ai/chat/character/voices/ to fix the check. I will work into making a fix soon.
Your token is not invalid, but this endpoint of the API seems to be broken. This is probably the c.ai team pulling the plug on old endpoints slowly.
Cheers
Is the 1.x branch going to get this fix in an update, or should we just wait for 2.0?
Hello, the 1.x branch will receive the fix by today or tomorrow.
Sorry for the lack of updates!
Hello, the experimental 1.2.8 version has been published. Please let me know if it resolves your issue
To update, use npm update.
Cheers
It no longer seems to give Authentication error, but now it gives me an error with Puppeteer
Unhandled Rejection at: Promise {
<rejected> TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
at Function.from (node:buffer:325:9)
at HTTPRequest._HTTPRequest_continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:233:18)
at HTTPRequest.continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:158:101)
at /Users/piipperi/Desktop/BraixenBot/node_modules/node_characterai/requester.js:204:41
at onceHandler (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:98:13)
at /Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:114:32
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async HTTPRequest.finalizeInterceptions (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:99:9) {
code: 'ERR_INVALID_ARG_TYPE'
}
} reason: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
at Function.from (node:buffer:325:9)
at HTTPRequest._HTTPRequest_continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:233:18)
at HTTPRequest.continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:158:101)
at /Users/piipperi/Desktop/BraixenBot/node_modules/node_characterai/requester.js:204:41
at onceHandler (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:98:13)
at /Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:114:32
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async HTTPRequest.finalizeInterceptions (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:99:9) {
code: 'ERR_INVALID_ARG_TYPE'
}
Hello, could you try uninstalling and reinstalling your packages?
I did, still the same error.
Hello, I will investigate the following issue.
Cheers
`[node_characterai] Puppeteer - This is an experimental feature. Please report any issues on github. [node_characterai] Puppeteer - Done with setup
WARNING: This version will be deprecated soon.
See: https://github.com/realcoloride/node_characterai/tree/2.0
===============================================================================
[node_characterai] Puppeteer - Eval-fetching is an experimental feature and may be slower. Please report any issues on github
node_modules/node_characterai/client.js:241 throw Error("Authentication token is invalid"); ^ Error: Authentication token is invalid at Client.authenticateWithToken (node_modules/node_characterai/client.js:241:15) at initChat Exited with code: 1`
Can anyone fix this ?? I'm sure that my Authentication token is valid. @realcoloride
Same error for me.
It no longer seems to give Authentication error, but now it gives me an error with Puppeteer
Unhandled Rejection at: Promise { <rejected> TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object at Function.from (node:buffer:325:9) at HTTPRequest._HTTPRequest_continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:233:18) at HTTPRequest.continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:158:101) at /Users/piipperi/Desktop/BraixenBot/node_modules/node_characterai/requester.js:204:41 at onceHandler (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:98:13) at /Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:114:32 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async HTTPRequest.finalizeInterceptions (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:99:9) { code: 'ERR_INVALID_ARG_TYPE' } } reason: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object at Function.from (node:buffer:325:9) at HTTPRequest._HTTPRequest_continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:233:18) at HTTPRequest.continue (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:158:101) at /Users/piipperi/Desktop/BraixenBot/node_modules/node_characterai/requester.js:204:41 at onceHandler (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:98:13) at /Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:114:32 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async HTTPRequest.finalizeInterceptions (/Users/piipperi/Desktop/BraixenBot/node_modules/puppeteer-core/lib/cjs/puppeteer/common/HTTPRequest.js:99:9) { code: 'ERR_INVALID_ARG_TYPE' }
I thought I could fix this error by changing this line
to this:
...(method === "GET" ? {} : { "postData": body } ),
because the postData was passing an empty object when the method was GET, which is not acceptable for a GET request, but...
then i run into an all new error "Failed saving & creating new chat" :(
It doesn't seem like my code change for GET should affect the save and create new chat function, so I assume this inability to create a new chat is related to a breaking API change in character ai.
Specifically it is this endpoint that is returning 500 errors for me https://beta.character.ai/chat/history/create/. I'll create a separate issue for that error.
Thanks for your help with library! I understand this is difficult work and character ai's api can be a moving target to keep up with.
Hello,
I'll investigate this.
Cheers
I thought I could fix this error by changing this line
to this:
...(method === "GET" ? {} : { "postData": body } ),because the
postDatawas passing an empty object when the method was GET, which is not acceptable for a GET request, but...then i run into an all new error "Failed saving & creating new chat" :(
It doesn't seem like my code change for GET should affect the save and create new chat function, so I assume this inability to create a new chat is related to a breaking API change in character ai.
Specifically it is this endpoint that is returning 500 errors for me
https://beta.character.ai/chat/history/create/. I'll create a separate issue for that error.Thanks for your help with library! I understand this is difficult work and character ai's api can be a moving target to keep up with.
Hello I can confirm I could replicate this. I did replace the line with the following commit (https://github.com/realcoloride/node_characterai/commit/a06c193357dd82371878e6d11f59de9bca812f19).
I will investigate endpoint errors.