Error in authorizing token {"error":"Unauthorized","status":401,"message":"Client ID and OAuth token do not match"}

I’m getting this error
{“error”:“Unauthorized”,“status”:401,“message”:“Client ID and OAuth token do not match”}

Here’s my code

const tmi = require('tmi.js');

var request = require('request');
var options = {
  url: '',
  method: 'GET',
  headers: {
    'Client-ID': 'ot6g07kdqko1i6iu1v5qulpkna1tj6',
    Authorization: 'Bearer <Auth TOKEN>' 

const client = new tmi.Client({
	options: { debug: true, messagesLogLevel: "info" },
	connection: {
		reconnect: true,
		secure: true
	identity: {
		username: process.env.USERNAME,
		password: '<PASS>'
  channels: [<Channel Name>]
const interestedToStream = {}
client.on('message', (channel, tags, message, self) => {
    if(self) return;
    if(message.toLowerCase() === '!test') {
        interestedToStream[tags.username] = tags.username
        request(options, function (error, response,body) { 
            if (error) throw new Error(error);

Help me with this.
Thank You in Advance

I’ve just revoked your OAuth token. You should NEVER share them publicly, they must be treated like a password and kept confidential.

Secondly, the reason you are getting an error that your OAuth token and Client ID don’t match is because your OAuth token wasn’t created by that Client ID.

If you want to use your own Client ID you need to generate a token yourself using either the Implicit or Auth code flows

If you use a token generated by some external site (which is not recommended) you will have to use their Client ID when making requests with that token.

I generated token from official site

Could please guide me how to create OAuth token and Client-ID on the official site?
I’m new Twitch.

The Auth docs explain the process to get a User token

You need to either use the Imiplicit Code Flow, which will generate a token that will last ~60 days but after it expires you’ll need to get a new one.

Or the authorization code flow which will return both an Access Token (that lasts ~4 hours), and a Refresh Token that will allow you to programmatically create new tokens when needed.

I tried again by creating new application on
here I generated password
but again I’m getting this error
{“error”:“Unauthorized”,“status”:401,“message”:“Invalid OAuth token”}
but for validating oauth i got

That’s not owned or run by Twitch. It’s just some 3rd party dev. So if you wanted to use OAuth tokens from that developer, you would need to make requests using their Client ID. Which again I don’t recommend.

Can I integrate chatbot IRC with API?

You can use the OAuth token you use to connect to Twitch Chat as a token for making API requests, but you can’t make requests through the chat connection itself.

Could you give me any sample code or any kind of video reference?

I suggest googling how to make HTTP requests in whatever programming language you’re working with, and then follow the Twitch Documentation as that explains what URLs, Querystring Params, and Headers, you need to use to make requests.

There is a nodeJS example for user authentication here

That may help you out.

It should be run as a separate “process” to your ChatBot

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