I’m making a simple bot that reads chat and stores messages that contain certain substring in a database
It seems that I don’t have any options but connecting to IRC. I don’t want to manually generate Access Token every time the old one got expired, I’d like to automize getting the code since all I need is to read chat.
My code is executed on backend so at first I was trying to use Client credentials grant flow. I’m able to get App Access Token using that flow, but IRC resopnds with “Login unsuccessful” error. I guess it’s because App Access Tokes doesn’t have any scopes.
Then I created a twitch user specially for my bot (I’ll call it bot-user) and tried Authorization code grant flow, but as I can see there is unskipabble step of navigating to an authorization page to get authorization code. I’ve authorized my bot-user (by going to that page manually and clicking ‘Authorize’ button) and it seems that I don’t have to click the button every time, but I still can’t figure out how to automize getting the code.
All I want to do is to read a chat on a certain steram, since I can see the chat even if I don’t have a twitch account I assume it’s possible, so basically there are two questions:
twitchSocket = new WebSocket(“wss://irc-ws.chat.twitch.tv:443”);
twitchSocket.addEventListener(‘open’, () => {
twitchSocket.send(PASS oauth:${oAuth}
);
twitchSocket.send(NICK ${nick}
);
twitchSocket.send(JOIN #${channel}
);
});
How do I get oAuth token with chat:read scope without authorization?
or
const postData = {
client_id: “myclientid”,
client_secret: “myclientsecret”,
code: “HOW DO I GET IT WITHOUT MANUAL AUTHORIZATION”,
grant_type: “authorization_code”,
redirect_uri: “http://localhost.”
};const requestOAuth = await axios.post('https://id.twitch.tv/oauth2/token',postData); oAuth = requestOAuth.data.access_token;
How do I get authorization code withong going manualy to authorization page? I’ve got my bot-user, can I use it to authorize automatically?