Getting Unauthorized Client ID and OAuth token do not match when using the webhook endpoint

I use axios to get the endpoint, my code is:
let access_token = ‘Bearer XXXXXXXXXX’

            let client_id = 'khXXXXXXXXXXXXXXXXXXXXXXXXXXXX85'

            const applications = axios.create({

                baseURL: 'https://api.twitch.tv/helix/webhooks',

                headers: {'Client_ID': client_id, 'Authorization': access_token, 'Content-Type': 'application/json'}

            })

            applications.post('/hub', {

                    "hub.callback": 'https://localhost',

                    "hub.mode": "subscribe",

                    "hub.topic": "https://api.twitch.tv/helix/streams?user_id=5XXXXXX6",

                    "hub.lease_seconds": 864000,

                    "hub.secret": "XXXXXXXXX!",

            }).then(d => console.log(d)).catch(err => console.log(err))

I got the acces token a few minutes before, it’s working wth other requests (such as the channels endpoint) but not with this one, what am i doing wrong?

Your client id header is wrong, it should be Client-ID, not Client_ID. The reason you’re getting a do not match error is because Twitch isn’t detecting your Client ID at all.

Also, you can’t use localhost as a callback for Webhooks or EventSub as that’s not a reachable destination for Twitch.

Thank you very much for the fast response, do you have any recommended places to temporarily target that callback untill I set something up?

The callback URL needs to be wherever you’ve set up your web server, and needs to be publicly accessible, (it also needs to be HTTPS for EventSub, or any webhook topics that require user scopes).

So you could host the webserver yourself and forward any ports needed to that so you can use your public IP as a callback URL, but honestly the best place to test would be wherever you actually plan to be running your app in production.

Thx, then I’ll make a webserver on the vps before I test this on it, again, thx for the help :blush:

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