I'm having problems with the oauth token

I can’t access the api with tmi.js, it tells me Error Logging in, i tried to get the token via helix api with the client-id and client secret, but nothing. I tried to generate an oauth token via twitchtokengenerator.com and use that, it logs in but the token is expired (using /validate via curl) so if I try to send a delete request to delete a message, it gives me the error 401.

Generally a code flow token is valid for 4 hours and a implicit token valid for 60 days.
TTGcom tends to provide an implicit token, so the token you get shouldn’t be dead yet.

Check the body of the response when deleting as the HTTP code is only half the info and the body describes the error

This soulds like you gave generated an app access/client credentials token rather than a usertoken.

For a chat bot you would generally use Getting OAuth Access Tokens | Twitch Developers

Which provides a code to exchange for an token and refresh token then when the token expires after around 4 hours, you use the refresh token to get a new token to operate with.

So

Check the body of the respose.

For a delete message this could be

  • invalid msg id
  • wrong token type
  • the user in the token isn’t the user in the query string params
  • the user in the token (and this the user in the query string) isn’t a moderator on the channel

The body will describe the problem.

The HTTP code if half the information needed to debug the issue

1 Like

I gave up on the idea that it was the token as soon as I saw that the TTG.com token gives it to me as expired, without checking if the error was given by something else.
in my code there is a function that takes the id of the broadcaster and the moderator, but being in an async function it returned a promise object instead of the id.

thank you very much. I appreciate it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.