Skip to content

Commit

Permalink
reduce scopes and improve token gen script
Browse files Browse the repository at this point in the history
- reduces the scopes needed to remove extra unused scopes
- added error handling in generate_token.py to handle ctrl+c
  • Loading branch information
DamienPup committed Apr 26, 2024
1 parent 2565052 commit 15f9cd3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ https://id.twitch.tv/oauth2/authorize
?client_id=CLIENT_ID_HERE
&redirect_uri=http://localhost:5000/auth
&response_type=token
&scope=channel:moderate+chat:edit+chat:read+channel:manage:broadcast+user:edit:broadcast+channel:read:redemptions+user:read:email
&scope=chat:read+chat:edit+channel:read:redemptions+user:read:email
```
2. Replace `CLIENT_ID_HERE` with your apps Client ID.
3. Paste this url into a brower, authorize the app, and wait for the browser to time out.
Expand Down
40 changes: 20 additions & 20 deletions generate_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,26 @@ def main():
server_thread = threading.Thread(target=run_server)
server_thread.start()

with open("CLIENT_ID.txt") as fp:
CLIENT_ID = fp.read()

TWITCH_AUTH_LINK = ("https://id.twitch.tv/oauth2/authorize"
f"?client_id={CLIENT_ID}"
"&redirect_uri=http://localhost:5000/auth"
"&response_type=token"
"&scope=channel:moderate+chat:edit+chat:read+channel:manage:broadcast+user:edit:broadcast+channel:read"
":redemptions+user:read:email")

print("=" * 25)
print("Open this link in your browser, if one doesn't open automatically.")
print(TWITCH_AUTH_LINK)
print("=" * 25)
webbrowser.open_new_tab(TWITCH_AUTH_LINK)

while not GOT_TOKEN:
time.sleep(0.1)

SERVER.shutdown()
try:
with open("CLIENT_ID.txt") as fp:
CLIENT_ID = fp.read()

TWITCH_AUTH_LINK = ("https://id.twitch.tv/oauth2/authorize"
f"?client_id={CLIENT_ID}"
"&redirect_uri=http://localhost:5000/auth"
"&response_type=token"
"&scope=chat:read+chat:edit+channel:read:redemptions+user:read:email")

print("=" * 25)
print("Open this link in your browser, if one doesn't open automatically.")
print(TWITCH_AUTH_LINK)
print("=" * 25)
webbrowser.open_new_tab(TWITCH_AUTH_LINK)

while not GOT_TOKEN:
time.sleep(0.1)
finally:
SERVER.shutdown()

if __name__ == '__main__':
main()

0 comments on commit 15f9cd3

Please sign in to comment.