EDIT: I kind of figured it out, I just need help with one more thing… I am using Auth Code method and then to gain the access token I need to call a function that calls
https://id.twitch.tv/oauth2/token ?client_id=<your client ID> &client_secret=<your client secret> &code=<authorization code received above> &grant_type=authorization_code &redirect_uri=<your registered redirect URI>
How do I do that… Should I put my redirect uri to localhost:3000/token and on that site I call that function or should I just add that after the redirect on my localhost:3000/authorization? As said in the title, I am using Flask.
@app.route('/') def index(): r = requests.get( 'https://api.twitch.tv/helix/streams') twitch_user = r return render_template('home.html', username=twitch_user)
^ Here is the only way I know how to do it, but it doesn’t work (401 Error) and it would be rather annoying doing that for every single request… Is there any other?
@app.route('/authorization') def authorize(): twitch_auth = requests.get( 'https://id.twitch.tv/oauth2/authorize?'+ # RESPONSE TYPE 'response_type=token'+ # TWITCH APP ID '&client_id='+app.client_id+ # REDIRECT URL '&redirect_uri='+app.redirect_uri+ # SCOPES - PERMISSIONS '&scope='+app.scopes) return redirect(twitch_auth.url)
Basically, I just need help with calling the get token function and where to put it and how to, for example, get the authorized users username and use it in HTML (I dont know how to put this into Flask using Requests)
curl -H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \ -X GET 'https://api.twitch.tv/helix/games?id=493057'