Hello! I am new to the forum, and using the Twitch OAuth link generator. I’ll try to be as comprehensive as I can. I am trying to create a chat bot that can read and write to a channel on the twitch account I created for this app. This bot is going to be talking on a channel that it does not own. Here is what I did:
from Getting OAuth Access Tokens | Twitch Developers :
https://id.twitch.tv/oauth2/authorize
?response_type=token
&client_id=jczoa3g95s0yn0ac9c816ffnaqmaok
&redirect_uri=https://localhost
&scope=channel:bot
&state=c3a68af509ea12e793af92361f002671
This got me into the account authorization page, which I then authorized. I verified that the link was on the account. This is what I recieved:
https://localhost/
#access_token=mygeneratedoauthtoken
&scope=channel%3Abot&state=c3a68af509ea12e793af92361f002671
&token_type=bearer
From here, I put the access token into the NodeJS program I am working on. I am using tmi.js as my package of choice to handle the read and write:
const client = new tmi.Client({
options: { debug: true },
connection: {
reconnect: true,
secure: true
},
identity: {
username: ‘ttvbot’,
password: ‘oauth:mygeneratedoauthtoken’
},
channels: [ ‘listeningchannel’ ]
});
I would expect this to be authorizing for my bot account which I authed in the web (ttvbot), and by plugging in the token from the response. From here if this were to auth, I would be able to read chat, and respond in other channels given some more logic. However, when I start the nodejs application, I get this error:
[15:58] info: Connecting to irc-ws.chat.twitch.tv on port 443…
[15:58] info: Sending authentication to server…
[15:58] error: Login authentication failed
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason “Login authentication failed”.] {
code: ‘ERR_UNHANDLED_REJECTION’
}
The root of it to me seems to be at the authentication. I’ve tried the “response_type=code” as well, but no luck. I’m not sure what else I can try. I am very confused by the verbiage used for determining which flow. Any help would be greatly appreciated.
Thanks,
Nick