Hello all.
New to OAuth stuff so please bear with me. Also English is not my first language, sorry if something is unclear.
I want to do a OAuth login using twitch, googled a lot and found Authlib in combination with Flask.
Followed all the docs, examples and tutorials I could find but I’m stuck at getting the access token. Here is my code:
app = Flask("Twitch")
app.secret_key = '123456'
oauth = OAuth(app)
oauth.register(
name='twitch',
client_id='{{ my_client_id }}',
client_secret='{{ my_client_secret }}',
access_token_url='https://id.twitch.tv/oauth2/token',
authorize_url='https://id.twitch.tv/oauth2/authorize',
api_base_url= 'https://api.twitch.tv/helix/',
client_kwargs={ 'scope': 'user:read:subscriptions' },
)
@app.route('/login')
def login():
redirect_uri= 'http://localhost:5000/auth'
return oauth.twitch.authorize_redirect(redirect_uri)
@app.route('/auth')
def auth():
token = oauth.twitch.authorize_access_token()
print(token)
return render_template('auth.html')
When calling “authorize_access_token” it returns “400 - missing client id” and I have no idea why. The redirect works fine: Get send to twitch, can authorize the app and get send back with the correct response (auth?code={{ my_code }}&scope=user%3Aread%3Asubscriptions&state=) I need for the access token but that is it.
Can anyone tell me what I’m doing wrong? I’ve been sitting here for hours and I can’t wrap my head around it.
Happy sunday and stay healthy.