(Python) Code worked once and now it's 401:Unauthorized

You’re likely getting an authorization code instead of an oauth token. I recommend reading https://github.com/justintv/Twitch-API/blob/master/authentication.md to better understand the oauth flow.