Python - Edit Stream Title (401 invalid oauth token)

Okay thanks. The above code (with .url) gives me the link to log in -> authorization -> access code. For the time being I can’t make my bot automatically log in (error message is similar to ‘Forbidden - missing csrf token’); I need to find the right csrf token and post it in the login form. I assume when getting this part right I can automatically grab the oauth token without needing to manually open a webpage.

As a workaround I’m just manually grabbing an access token from https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=INSERT_CLIENT_ID&redirect_uri=http://localhost&scope=channel_editor and then using the below code to edit my stream title, which seems to work fine.

		putURL = "https://api.twitch.tv/kraken/channels/" + config.CHANNEL
		putHeaders = {"Authorization": "OAuth " + config.OAUTH_TOKEN,
					'Client-ID': config.CLIENT_ID}
		putData = {"channel[status]": streamTitle}
		putResponse = requests.put(url=putURL, headers=putHeaders, params = putData)

Do these oauth tokens expire over time?