App token invalid

After getting the token through the post request, when sending it by the curl request I get an ERR_INVALID_HTTP_TOKEN (statuscode:200).

Display your curl request with the token redacted

It is a discord bot written in discord.js (with Discord Bot Maker app).

This is my command code:

{"name":"store","permissions":"NONE","restriction":"1","_id":"qFdDF","actions":[{"behavior":"0","interpretation":"0","code":"const fetch = require(\"node-fetch\");\nfetch('https://id.twitch.tv/oauth2/token?client_id=XXXXXXXXXX&client_secret=XXXXXXXXXXXXXXXXXXXXXXX&grant_type=client_credentials', {\n method: 'post'\n })\n .then(res => res.json())\n .then(json => {\n console.log(json);\n const token = json.access_token;\n Actions.storeValue(token, 1, \"token\", cache)\n });","storage":"0","varName":"","name":"Run Script"},{"time":"5","measurement":"1","name":"Wait"},{"channel":"0","varName":"","message":"${tempVars(\"token\")}","storage":"0","varName2":"","iffalse":"0","iffalseVal":"","name":"Send Message"},{"token":"${tempVars(\"token\")}","user":"","pass":"","url":"https://api.twitch.tv/helix/streams","path":"","storage":"0","varName":"","debugMode":"1","headers":"-H \"Authorization: Bearer ${tempVars(\"token\")}\"\n-H \"Client-ID: nds0mn52n8x9iffq928jfn83x2youd\"","name":"Store Json From WebAPI"}]}

And this is the console error REMOVED

I know nothing about the Discord Bot Maker app. But this does look like it’s invoking a call to node fetch and this looks wrong

“headers”:"-H "Authorization: Bearer ${tempVars("token")}"\n-H "Client-ID: nds0mn52n8x9iffq928jfn83x2youd"

Looks like it should be

“headers”:“Authorization: Bearer ${tempVars("token")}\nClient-ID: nds0mn52n8x9iffq928jfn83x2youd”

Instead. You are saying “go add this header” and then adding the curl -H flag, which is the flag for “go add this header” so you are saying “go add this header go add this header”

Thank you very much for your help here and in discord. I will try to continue developing the bot again with this info. I’m sure I may have more trouble down the road :slight_smile:

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