I can't get channel editors by using bot irc commands - authentication failed

Hello.
I create my own chatbot, get OAuth token in https://twitchapps.com/tmi/ and try to get channel editors for the "twitch"channel. My bot receives the answer: {‘error’: ‘Unauthorized’, ‘status’: 401, ‘message’: ‘authentication failed’}
At the same time, this bot can receive chat messages and send a response to it.
What is the cause of the error?

This website only gives you a token with the scope chat_login can’t do anything with that apart from connect to chat.

You can read the following docs about Authentication and scopes:

Thank you!

I’m trying to figure out how to get the right token with documentation article that you sent me.
But there are a few questions that I do not understand.
I’m using the V5 API.

  1. What should I write in the grant_type parameter, the documentation says “This must be client credentials”, but what are these “client credentials”?
  2. Why, in the example, the token lifetime is 3600 seconds, whereas the above App access token description says " App access tokens expire after about 60 days"
  3. I didn’t quite understand the scopes specified in the https://dev.twitch.tv/docs/authentication/#scopes
    The following features are required for my bot:
    a. To connect to different channels
    b. To be able to read messages in these channels (to receive commands from users)
    c. To be able to get the channel id by channel name (in order to execute command of enabling bot in channel)
    d. To be able to get a list of channel editors by channel id (in order to be able to determine whether this user has the rights to initiate the work of the bot in the channel, so that the random user could not add the bot to the channel)
    e. Be able to send whisper to users (in response to their commands)
    f. Get the user id by username and get the user by user id to find it in our database, to execute the commands requested by them.
    What scopes should I connect to be able to perform all these actions using the API v5?

I do not know how it is accepted in Twitch, whether it is necessary to check at the user who wants to connect a bot to the channel, the rights of the editor of the channel or not?

  1. Literally just the word client_credentials
  2. Different kinds of tokens have different token lengths
    • a/b chat_login
    • c none needed
    • d you would need a permission from the channel owner, so you won’t be able to get that permission. For such a thin ONLY allow broadcasters to add the bot, not channel editors.
    • e chat_login
    • f none needed

Specifically this flow: https://dev.twitch.tv/docs/authentication/#oauth-authorization-code-flow-user-access-tokens

Do whatever you think works best for your bot. Or as I noted above under d

OK, but if I understand correctly, I can get this token with chat_login skope using the link https://twitchapps.com/tmi/
And not sending requests anywhere else. Or am I wrong?

Do I understand correctly that the channel name and the username of the broadcaster are the same. And in order to understand that broadcaster requested to add a bot to the channel, I just need to compare the name of the channel and the username of the user who sent the request?

yes

And token from https://twitchapps.com/tmi/ is all of I need for my scope of bot activity?

Seems so, as we discussed

Thank you so much for your help and answers, you helped me a lot in this difficult task!!!

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