IRC with Python - Login fails

Interesting. I requested a fresh user access token and your tool says it is an invalid token.
I generate my user access token by using this script stuff:

from flask import Flask
from flask import request
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop

import threading
import time

from config.app_credentials import client_id

def get_user_access_token(scopes=[]):
    app = Flask(__name__)
    io_loop = None
    http_server = None
    scope_string = ' '.join(scopes)

    code = None
    received = False

    @app.route("/")
    def root():
        baseURL = "https://id.twitch.tv/oauth2/authorize"
        redirectUri = "http://localhost:25000/callback"
        url = baseURL + '?response_type=code&client_id=' + client_id + '&redirect_uri=' + redirectUri + '&scope=' + scope_string

        # TODO Create fancy html page with a button to go to the twitch logon page
        return "Landing page on the server.\n <a href='" + url + "'>Authorize user account from Twitch</a>"

    @app.route("/callback")
    def callback():
        nonlocal received
        nonlocal code

        code = request.args.get('code')
        if code is None:
            print("Callback ohne Code Parameter aufgerufen!")
        received = True
        return code

    def start_server():
        nonlocal io_loop
        nonlocal http_server

        # Start its own IOLoop
        io_loop = IOLoop()
        io_loop.make_current()

        # Defining the server
        http_server = HTTPServer(WSGIContainer(app))
        http_server.listen(25000)

        # Start the actual processing of the server
        io_loop.current(instance=False).start()

        print("Server is stopped now.")

    def stop_server():
        nonlocal http_server
        nonlocal io_loop
        http_server.stop()
        io_loop.make_current()
        io_loop.current(instance=False).stop()
        io_loop = None
        http_server = None

    tserver = threading.Thread(target=start_server, daemon=True)
    tserver.start()

    # Wait until the Twitch Auth process called our callback page.
    while not received:
        time.sleep(0.1)
    time.sleep(0.1)

    stop_server()

    return code

I just call the function with a scope array like ["chat:edit", "chat:read"]

It opens a simple webserver with a link on it. I click the link, get redirected to twitch to authorize it and then I have a new key. When I now call the link at the page, I just get redirected to my callback page with a new token - Twitch probably saved that I used this client id and so on for my account with the exact same scopes and does not ask again if it is a valid request, right?

How can it be invalid right when i requested it?