I am trying to use the new Channel Points API to create a redemption programmatically when I trigger an event. I am using a JS library called Axios to send HTTP requests. I am unsure if I am getting the correct access_token from the first post causing the error shown below.
axios.post(https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=${client_id}&redirect_uri=${redirectURL}&scope=channel:manage:redemptions
)
.then(response => {
// console.log(response.data.access_token)
axios.post(‘https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id={my_ID}’, {
headers: {
“Client-ID”: client_id,
“Authorization”: "Bearer " + response.data.access_token
},
}, {
“title”: “game analysis 1v1”,
“cost”: 50000
}).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.log(error);
});
}).catch(function (error) {
console.log(error);
})
This is the error I am getting from this request
{ status: 401, message: ‘invalid csrf token’ }