I have a chat bot written in .NET/C#, it doesn’t use web browser and all communication is done via Twitch API. I decided to add functionality for setting stream title and game. This requires authentication and and corresponding scope usage (channel_editor).
I have client_id, client_secret, OAuth token. Also bot is set as moderator on my channel, but it still needs to be authenticated in order to get access_token which is required for “PUT /channels/:channel/”.
There’s no need in authentication for data read, in some cases OAuth may be required. But in this case it intends to update channel data. When I try to get access_token I’m redirected to app authentication page instead of being redirected to page with code (https://[your registered redirect URI]/?code=[CODE]). But I cannot authorize it because I see this page only in httpWebResponse as byte array.
There’s no way around the browser requirement, but you can get a token outside of the bot and then place it in its configs/settings/whatever. One option would be to make a website to handle the authorization, which would then send the token to the bot automatically.
I tried to retrieve token in the browser and save it (let’s say in DB). But it seems that this token expires after one usage in any web request. Because next request demands new token or authentication.
Oh, it seems I understood what I was doing wrong. I need to go through the flow as described for “Authorization Code Flow” up to the step with the following response:
{
“access_token”: “[user access token]”,
“scope”:[array of requested scopes]
}
And use this access_token in PUT request scenario for setting channel title. And this is the token which doesn’t expire as 3ventic said. Am I right?