Authenticating with Twitch API using Python

Hello,

I use the following API in Python: https://github.com/TronPaul/twitchingpython/blob/master/twitchingpython/

The twitchingpython api throws an exception and i found out that it’s doing that because my token is invalid (but it is not, i double checked with direct url in my browser).

Python Code:

#!/usr/bin/python

import twitchingpython

token = "mytoken"
channel = 'nullby7e'
status  = 'new_status'
game    = 'new_game'

wrapper = twitchingpython.TwitchingWrapper(token)
wrapper.updatechannel(channel, status, game)

I also have a question about this on stackoverflow with a similar Python script, without the twitchingpython API.

http://stackoverflow.com/questions/24767169/set-channel-information-using-the-twitch-api

On an offtopic note; I am not receiving an activation mail for my other Twitch Developers account: NullBy7e.
It’s been two days since I registered.

If you are getting a 401 error, it is most likely that your token is invalid, or that you aren’t sending the token properly for some reason. Assuming your wrapper is used by other people and not buggy, it’s reasonable that your token is not valid, or does not possess the scopes required to update channel information.

You can check if an oauth token is valid and what scopes it has by GETting https://api.twitch.tv/kraken/?oauth_token=TOKEN. Updating channel status and game requires the channel_editor scope.

It may be a confusion on my part.
I generated the OAuth token with TMI and it doesn’t have the channel_editor scope.

I used this: http://www.twitchapps.com/tmi/ to get my token and I should have read better.

EDIT:

I tried to get my token via: https://api.twitch.tv/kraken/oauth2/authorize and I get this:

{"error":"Not Found","status":404,"message":null}

https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=clientid&redirect_uri=hyperbot.tv&scope=channel_editor

I think you meant to visit https://api.twitch.tv/kraken/oauth2/authenticate

Now I get: ?

error=redirect_uri_mismatch&error_description=Parameter+redirect_uri+does+not+match+registered+URI

The redirect url I entered is the same as the url set in the client id account.

Make sure the uri is exactly the same. Ex:
http://discuss.dev.twitch.tv/ discuss.dev.twitch.tv
Every character must be the same, even if they point to the same ip.

Yep it’s the same, I set the url to hyperbot.tv on the account that belongs to the client id.

Don’t forget to include the protocol as well:

hyperbot.tv should be http://hyperbot.tv or https://hyperbot.tv if you are using SSL.