I don’t quite understand your code, you seem to be doing things out of order, mixing things from different OAuth flows and request libraries.
From the looks of this you’re trying to get the access token from the URL Hash, yet that’s not the OAuth flow you’re using so there wont be an access token in the URL.
You’ve got a request to the Users endpoint before you’ve even got the access token? After the user is redirected to your redirect URI you’ll only have the code at that point, not an access token.
As for your final request, to the custom rewards endpoint, your arguments are in the wrong order, you’re using axios.post(url, config, data), when it’s expecting axios.post(url, data, config), so you’re getting an OAuth token is missing error because you’re sending your data as the config object (of which none of the fields will actually do anything as there isn’t a title or cost request option.
So for the first part, I took the code from Barry Carlyon’s Github where he had created a website to get you the access_token. And simply changed the client_id, redirect url, and added a scope in order for it to work with channel point redemption. It does give me a code, but I am unsure after what you said if its the access token or just a code. When using it later to get the access token and refresh token it seems to work fine.
The Auth Code flow doesn’t return any URL hash, it returns a code in the querystring params, which your backend server needs to then exchange for an Access Token and Refresh token. This auth flow is for making requests server-side, as your frontend wont have access to the client secret needed to exchange that code for tokens.
Ok, I am confusing myself and you when explaining this. I want to make these requests to create new channel redemptions server side. This is why I changed it to token_type=code.
After getting this code on the client-side I manually put it in my server-side code (just for now while testing) so that I get the access token and refresh token as shown in my very first message I posted. After getting the access token and refresh token I then try to make the request for a creation of a new redemption. That is where I feel I am having issues.
Output after requesting an access and refresh token
On every request for an access and refresh token, it always says that manage channel redemptions is within my scope. So unsure why it is saying incorrect user authorization.
First, don’t EVER share access tokens or refresh tokens. they are to be treated as confidential tokens and as such to share them is a violation of the developer agreement. Because you’ve leaked the token I’ve just revoked it so that it can’t be misused.
Secondly, just to check, does the user going through the OAuth flow match that of the channel you’re trying to use the channel points endpoints for? eg, if you go through the OAuth flow, you can only use that OAuth token with your broadcaster id.
If I understand you yes, I created an app in the dev console. Got the client id and client secret. Client-side when I make the request for the code I use the client id I got from the app and use the redirect uri from the same app. Server-side I use the same client id and client secret from the app to complete everything. The only issue I may see is my Broadcaster_id is incorrect. It is the same id that I use when using the twitch pubsub, but there its called the “channel_id” in the documentation. Are those two different things?
user/channel/broadcaster id are all the same thing, they are just named differently depending on context.
If you’re sure the id is correct, then the only other thing I can suggest is you double check your URL that you’re posting to.
I’m not sure if the code you pasted here lost some syntax or formatting in pasting, but url: ‘https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id={broadcaster_id}’ will send the post to that exact URL, you need to add your id to the broadcaster_id param, because based on what you’ve pasted you’re literally sending the text {broadcaster_id}, rather than 123456 or whatever your id is.
Idk why it lost the $ when pasting, I actually have it written as so
broadcaster_id=${broadcaster_id}
So it definitely does replace it with the proper number.
I am entirely unsure why it is giving me that error. I get an access token, refresh token, all while using the same broadcaster id, client id, and client secret.
Most likely the forum is removing it as you are just pasting code in and not telling the forum it’s code, so it does some odd stuff when you paste code and don’t tell it it’s not code. Sometimes you do this correctly and sometimes you don’t
So, to see where we are now can you post your current code that you are using? And correctly format it
Paste it in, select it all and hit
Or start every code line with (at least) four spaces (and a new line above/below the code block
I actually found out that I was wrongly logged into the incorrect twitch login when testing, resulting in the Auth token not working properly. It works perfectly now. The issue I am having now though is when creating new redemptions the images are not showing up.