Skip to content

twitch.py: eval client_id and token when used with secures #555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#
# # History:
#
# 2024-06-20, stacyharper
# v0.10: eval client_id and token expressions. Usefull when used with weechat secures values.
# 2020-07-27,
# v0.9: added support for Oauth token to support twitch APIs requirement -mumixam
# fix bug for when api returns null for game_id -mas90
Expand Down Expand Up @@ -552,6 +554,8 @@ def config_setup():
hlist = []
cidv = weechat.config_get_plugin(option)
tokv = weechat.config_get_plugin('token')
if tokv[:6] == "${sec.":
tokv = weechat.string_eval_expression(tokv, {}, {}, {})
if cidv:
hlist.append('Client-ID: '+cidv)
if tokv:
Expand All @@ -562,6 +566,8 @@ def config_setup():
hlist = []
cidv = weechat.config_get_plugin('client_id')
tokv = weechat.config_get_plugin(option)
if tokv[:6] == "${sec.":
tokv = weechat.string_eval_expression(tokv, {}, {}, {})
if tokv:
hlist.append('Authorization: Bearer '+tokv)
if cidv:
Expand Down Expand Up @@ -592,6 +598,8 @@ def config_change(pointer, name, value):
curlopt['httpheader'] = x + '\n' + "Client-ID: " + value
break
if option == 'token':
if value[:6] == "${sec.":
value = weechat.string_eval_expression(value, {}, {}, {})
for x in curlopt['httpheader'].split('\n'):
if x.startswith('Client-ID:'):
curlopt['httpheader'] = x + '\n' + "Authorization: Bearer " + value
Expand Down
Loading