IRC with Python - Login fails

You don’t seem to be exchanging the returned code for an Access Token, which is step 3 in the Auth Code flow https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-authorization-code-flow