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.
If you’re using the Auth Code flow, step 1 is to send the user whose channel you wish to get permissions for to the OAuth link. You don’t make an axios request, you need to send the user to that actual URL.
If the user accepts, they’ll be redirected to your redirect URI, at which point your server can exchange the code for an access token as documented.
Once your server has exchanged the code for an access token and refresh token, then you can make API requests.
You can use an access token until it expires. With the Auth Code flow, you’ll also get given a refresh token along with the access token so you can programmatically get a new set of tokens when needed without the user needing to go through the process again https://dev.twitch.tv/docs/authentication#refreshing-access-tokens
I don’t have any examples to hand, as the docs themselves are pretty self-explanatory.
Send user to Twitch to request permission from them
The user is sent back to your server with a code in the querystring if they accept
your server exchanges the code for access and refresh tokens.
For specifics on how you create a web server to handle steps 2 and 3 there are plenty of tutorials on Google, or YouTube, for most programming languages that can host web servers and make HTTP requests.