I’m trying to send a message as my bot, but I’m running into some trouble.
I’m making the following request:
post("https://api.twitch.tv/helix/chat/messages")
.header("Authorization", format!("Bearer {}", token))
.header("Client-ID", client_id)
.header("Content-Type", "application/json")
.json(&json!({
"broadcaster_id": user_id,
"sender_id": bot_id,
"message": content
}));
Where token
is the token I got from curl -X POST -d client_id=REDACTED -d client_secret=REDACTED -d grant_type=client_credentials "https://id.twitch.tv/oauth2/token"
, client_id
is the client id of my bot, user_id
is the id of the user whose chat I want to send a message to, and bot_id
is the id of my bot user.
However, when making this request, I get a 401 stating ‘The sender must have authorized the app with the user:write:chat and user:bot scopes.’
What am I doing wrong?
NOTE: When sending a request with bot_id
the same as user_id
and having token
as the user token, it does work, but then I send a message as the user instead of as my bot, which is not what I want.