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 import os import praxis_logging praxis_logger_obj = praxis_logging.praxis_logger() praxis_logger_obj.init(os.path.basename(__file__)) praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__)) 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: praxis_logger_obj.log(scope_) auth = UserAuthenticator(self.twitch, self.target_scope, force_verify=True) token, refresh_token = auth.authenticate() if token is not None: praxis_logger_obj.log("found token") if refresh_token is not None: praxis_logger_obj.log("found refresh_token\n") praxis_logger_obj.log("token: ", token) praxis_logger_obj.log("refresh_token: ", refresh_token) praxis_logger_obj.log("") 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() praxis_logger_obj.log("Ready to close") input()