Total newbie: auth and commercial

Being a newbie, I am going to ask very naive questions.

We have a video stream published to an RTMP endpoint. Our customer wants to designate periods in the stream where commercial advertisements may be injected. It should be emphasized that the stream is running 24/7; therefore, unattended. Indeed, we have dozens of streams.

We have been pointed to the v5 API, channels, with https://api.twitch.tv/kraken/channels/<channel ID>/commercial. This requires a token with scope, channel_commercial.

I think I have worked my head around client ID and channel ID and how to obtain those. As I said, total newbie and this was a big hassle.

Next problem, authentication. Unattended.

First, type of token: user or app? Looks like app is the correct type for a server talking to another server. But, the docs says “Some Twitch API endpoints require application authentication”. I have yet to see a list of the fabled “some”. Every API I have tried rejects the obtained token (except https://api.twitch.tv/kraken/oauth2/revoke).

So, I am assuming user type. But, I am failing to find a means of doing this unattended. But, I might be leaping too far ahead.

Next decision is flow. Since client credentials are not working, that leaves implicit code and authorization code.

This is where I am stuck.

If you have a look at the docs for App access tokens, it mentions “Since app access tokens are not associated with a user, they cannot be used with endpoints that require user authentication.” and also “They enable you to make secure API requests that are not on behalf of a specific user.”. What you are attempting to do though IS making a request on behalf of a specific user, in this case you want your app to start commercials on behalf of whatever channel you’re doing this for.

Which authentication flow you use is up to you and depends on your app, but you will need a User access token with the channel_commercial scope. This can’t be done ‘unattended’, it requires someone to actually be logged in to the Twitch account that you want to start commercials for, and go through the authentication process with your app. Once that is done though, and you have an OAuth token with the correct scope, you will be able to use the commercial endpoint for that specific channel.

1 Like

Thanks for the confirmation. I did suspect that. But, needed to check to see if anybody had built the kind of service we are trying to do.

We clearly need to work on a partner relationship with twitch in order to get the API needed to support a production video stream. This actually an exciting opportunity. I just need to bring in our business development guys.

Only the initial authorization requires user interaction, the application can refresh access tokens unattended.

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