Skip to content

Commit 66a5c65

Browse files
authored
Fix protected endpoints for Twitch (#66)
* Fix protected endpoints for Twitch Twitch.tv now requires the Client-ID used to generate an oauth token to be sent to protected requests along with the token. * Add comment
1 parent ee90ae9 commit 66a5c65

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

loginpass/twitch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
from ._core import map_profile_fields
1717

1818

19+
def twitch_compliance_fix(session):
20+
21+
# https://discuss.dev.twitch.tv/t/requiring-oauth-for-helix-twitch-api-endpoints/23916
22+
def fix_protected_request(url, headers, data):
23+
headers["Client-ID"] = session.client_id
24+
return url, headers, data
25+
26+
27+
session.register_compliance_hook(
28+
'protected_request', fix_protected_request)
29+
30+
1931
def normalize_userinfo(client, data):
2032
return map_profile_fields(data[0], {
2133
'sub': 'id',
@@ -39,6 +51,7 @@ class Twitch(object):
3951
},
4052
'userinfo_endpoint': 'users',
4153
'userinfo_compliance_fix': normalize_userinfo,
54+
'compliance_fix': twitch_compliance_fix,
4255
}
4356

4457

0 commit comments

Comments
 (0)