I’m facing a strange problem, looping over a few username to get their respective IDs, but one gives me 401 error. I’m posting the one that returns me error and another working fine so you all can see.
The one that’s giving error.
link = 'https://api.twitch.tv/helix/users?login=' + username
>>> https://api.twitch.tv/helix/users?login=cerbero_podcast
async with aiohttp.ClientSession() as session:
async with session.get(link, headers={'Client-ID': client_id, 'Authorization': twitch_token}) as resp:
>>> print(resp)
<ClientResponse(https://api.twitch.tv/helix/users?login=cerbero_podcast) [401 Unauthorized]>
<CIMultiDictProxy('Connection': 'keep-alive', 'Content-Length': '69', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache, no-store, must-revalidate, private', 'Content-Type': 'application/json; charset=utf-8', 'Expires': '0', 'Pragma': 'no-cache', 'Server': 'envoy', 'timing-allow-origin': 'https://www.twitch.tv', 'twitch-trace-id': 'd2187cbca3a82dfc22c46ab9d8b61798', 'x-ctxlog-logid': '1-5ed6531d-3fb73c2bac2dab247b99b540', 'Date': 'Tue, 02 Jun 2020 13:24:45 GMT', 'X-Served-By': 'cache-sea4462-SEA, cache-fra19143-FRA', 'X-Cache': 'MISS, MISS', 'X-Cache-Hits': '0, 0', 'X-Timer': 'S1591104285.098942,VS0,VS0,VE160', 'Vary': 'Accept-Encoding', 'Strict-Transport-Security': 'max-age=300')>
The one that’s working fine.
link = 'https://api.twitch.tv/helix/users?login=' + username
>>> https://api.twitch.tv/helix/users?login=berritv
async with aiohttp.ClientSession() as session:
async with session.get(link, headers={'Client-ID': client_id, 'Authorization': twitch_token}) as resp:
>>> print(resp)
<ClientResponse(https://api.twitch.tv/helix/users?login=berritv) [200 OK]>
<CIMultiDictProxy('Connection': 'keep-alive', 'Content-Length': '453', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache, no-store, must-revalidate, private', 'Content-Type': 'application/json; charset=utf-8', 'Expires': '0', 'Pragma': 'no-cache', 'ratelimit-limit': '800', 'ratelimit-remaining': '799', 'ratelimit-reset': '1591104287', 'Server': 'envoy', 'timing-allow-origin': 'https://www.twitch.tv', 'twitch-trace-id': '12b8372efccfe6b92d006f3aef34b050', 'x-ctxlog-logid': '1-5ed6531e-dfcf49f09b484604f680f043', 'Date': 'Tue, 02 Jun 2020 13:24:46 GMT', 'X-Served-By': 'cache-sea4430-SEA, cache-fra19149-FRA', 'X-Cache': 'MISS, MISS', 'X-Cache-Hits': '0, 0', 'X-Timer': 'S1591104286.401778,VS0,VS0,VE180', 'Vary': 'Accept-Encoding', 'Strict-Transport-Security': 'max-age=300')>