Hello everyone.
I’m trying to get my chatbot to set the title of a stream via chat commands.
I registered the application with the scopes channel_editor and user_subscriptions and got the authtoken it returned. Accessing the subscriptions with a get-request works, but everytime I try to set the streamtitle it returns a 401. I should have permission to do this though.
For the bot I use Java and this is the code snipped thats supposed to change the title.
String url = "https://api.twitch.tv/kraken/channels/<name>?oauth:<token>";
URL obj = new URL(url);
HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
conn.setRequestProperty("Accept", "application/vnd.twitchtv.v2+json");
conn.setRequestMethod("PUT");
conn.setDoOutput(true);
String data = "channel[status]=Please+work!&channel[game]=Something";
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(data);
out.flush();
for (Entry<String, List<String>> header : conn.getHeaderFields().entrySet()) {
System.out.println(header.getKey() + "=" + header.getValue());
}
Am I doing something wrong?