How to get programmatically the oauth token after redirect?

Sorry that was a mistake on my definition of the problem,

I am trying out the Authorization flow.
What i am not currently able to achieve is to extract the code programmaticaly from the url the user is getting redirected (before the POST request).

For example:

@app.route("/")
def redirect_for_auth():
return redirect("https://id.twitch.tv/…?response_type:…?..)

redirects the user to the correct url to login and be provided with a code to be later posted for an auth token exchange.

What i am trying to achieve is to get this url server side without another redirection for the client if that makes any sense

Thanks a lot for your help.