Search code examples
c#oauthtwitch

Get 401 Error if i try to change twitch.tv status or game title


I get an oauth token with the Implicit Grant Flow and the scope channel_editor. If I try to change the the channel title the answer from twitch server is 401 Token invalid or missing required scope.

Thats the code i try to change the channel status:

var client = new RestClient("https://api.twitch.tv/kraken/channels/innoszorn83");
        var request = new RestRequest(Method.PUT);
        request.AddHeader("cache-control", "no-cache");
        request.AddHeader("content-type", "application/json");
        request.AddHeader("authorization", "OAuth " + cs_globals.oauth);
        request.AddHeader("accept", "application/vnd.twitchtv.v3+json");
        request.AddParameter("application/json", "{\"channel\":{\"status\":\"Hello World\"}}",
            ParameterType.RequestBody);

        IRestResponse response = client.Execute(request);

I get the oauth about a webbrowser control in my c# programm.


Solution

  • I found the solution. I have one error in my code. I doesn't change the scope to channel_editor