Commerical API 401ing?

I’m trying to figure out how to use Twitch’s API from JS SDK to run commercials outside of the Dashboard in hopes it doesn’t log me out randomly (many have this problem). I’m a bit of an idiot with using this right now, but I can grab an Access Token just fine and do some things with it, but when I try to use the Token to run a commercial, it returns 401 for invalid Token & Scope. I definitely auth the token with channel_commercial. If it isn’t scope, how can it be the auth token if it’s still valid for other API calls? Here is the code:

$('.runcommercial').click(function() {
          Twitch.api({method: 'channels/bizkit047/commercial', verb: 'POST'}, function(error, channel) {        

Also not entirely sure how long Access Tokens can stay valid. Should they still work if you close out of the page and come back later to do more API calls, or should a new token be requested every time the user wants to do something like run a commercial?

The tokens should stay valid until a new one is requested or the application is disconnected from the account connection settings.

That’s what I figured, so I’m somehow sending the request wrong I’d assume?

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