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.
So here is how I do it [Authorization Code Flow]:
String.Format(“https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id={0}&redirect_uri={1}&scope=channel_editor&state={2}”, CLIENT_ID, REDIRECT_URI, OAUTH_TOKEN);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.Method = “GET”;
using (var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
{
//response URL is expected here
}
I also tried Implicit Grant Flow, but result is the same. Bot needs authentication.
Is there any way to get access_token in order to set stream title and game? Or what am I doing wrong?
