I’m working on linking twitch user email to my custom app with user auth flow. Currently i am able to get a token from Twitch API however when i send the oauth token to get the users email i get this response.
{"error":"Unauthorized","status":401,"message":"Invalid OAuth token"}
I’m getting a new token after every request for authorization and I’m trying to use it with the following python code to request the email.
@api_view(['GET'])
def save_twitch_user_token(request):
params = {
'code': request.query_params['code'],
'scope': request.query_params['scope']
}
endpoint = "https://api.twitch.tv/helix/users"
headers = {
'Authorization': 'Bearer %s' % params['code'],
'Client-Id': settings['TWITCH_CLIENT_ID']
}
response = requests.request(method='GET', url=endpoint, headers=headers)
url = settings['FRONTEND_CALLBACK_URI']
return HttpResponse(response.text, status=status.HTTP_200_OK)
This is as far as i’ve gotten. I’m wondering if me getting all these different tokens are messing me up somehow? any help is appreaciated. Thanks.