404 message when trying to retreive API token

Thank you for the response Barry. I tried what you said and am now receiving:

code=REMOVED
{"status":400,"message":"Invalid authorization code"}

<Response [400]>
127.0.0.1 - - [23/Feb/2019 00:17:58] "GET /post/?code=REMOVED&scope=channel%3Aread%3Asubscriptions HTTP/1.1" 200 -

oauth = str(oauth[28:58])
print(oauth)
get = requests.post("https://id.twitch.tv/oauth2/token?client_id=70abzn2qkdy5hv5z3eqv44895b7dyp&client_secret=REMOVED&code=(%s)&grant_type=authorization_code&redirect_uri=http://localhost/post/" % oauth)
print(get.text)
print(get)
return render_template('index.html', title='Home')

Any idea? Maybe its the way Flask is handling the HTTP requests? I’m certainly grabbing that code from the return URL and passing it into the post request. I tried to disconnect and reconnect my application as well.

EDIT: Fixed, this was happening because the post request needs to get sent after the GET request finishes. Have to learn Flask a little bit more to learn how to handle the data correctly. Thanks a bunch for your help.