From da7defc7f293bc790ff5ad9bf6b6ee950cd47fce Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Sun, 25 Apr 2021 00:52:46 -0400 Subject: [PATCH] Create twitch_generate_credentials.py --- twitch_generate_credentials.py | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 twitch_generate_credentials.py diff --git a/twitch_generate_credentials.py b/twitch_generate_credentials.py new file mode 100644 index 0000000..cfabaee --- /dev/null +++ b/twitch_generate_credentials.py @@ -0,0 +1,49 @@ +import credentials + +import config + +import twitchAPI +from twitchAPI.pubsub import PubSub +from twitchAPI.twitch import Twitch +from twitchAPI.types import AuthScope +from twitchAPI.oauth import UserAuthenticator +from pprint import pprint +from uuid import UUID + + +class Twitch_Credential_Maker(): + def __init__(self): + super().__init__() + self.credential : credentials.Twitch_Credential() + self.twitch : Twitch() + self.target_scope = [AuthScope.WHISPERS_READ, AuthScope.CHANNEL_READ_REDEMPTIONS] + + def get_tokens(self): + self.twitch.authenticate_app(self.target_scope) + for scope_ in self.target_scope: + print(scope_) + auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) + token, refresh_token = auth.authenticate() + + if token is not None: print("found token") + if refresh_token is not None: print("found refresh_token\n") + print("token: ", token) + print("refresh_token: ", refresh_token) + print("") + return token, refresh_token + + + + +if __name__ == "__main__": + testModule = Twitch_Credential_Maker() + + credentials_manager = credentials.Credentials_Module() + credentials_manager.load_credentials() + testModule.credential = credentials_manager.find_Twitch_Credential(config.credentialsNickname) + testModule.twitch = Twitch(testModule.credential.pubsub_client_id, testModule.credential.pubsub_secret) + #pprint(testModule.twitch.get_users(logins=['thecuriousnerd'])) + + testModule.get_tokens() + print("Ready to close") + input() \ No newline at end of file