From 42113ed4972e18f28a8c44bac135230b4b91e889 Mon Sep 17 00:00:00 2001 From: anas Date: Sat, 25 Sep 2021 05:46:50 +0300 Subject: [PATCH] fix --- .../mirror_utils/upload_utils/gdriveTools.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index cbe28b8..57c323b 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -580,21 +580,19 @@ class GoogleDriveHelper: LOGGER.info("Authorize with token.pickle") with open(self.__G_DRIVE_TOKEN_FILE, 'rb') as f: credentials = pickle.load(f) - if credentials is None or not credentials.valid: - if credentials and credentials.expired and credentials.refresh_token: - credentials.refresh(Request()) - else: - flow = InstalledAppFlow.from_client_secrets_file( - 'credentials.json', self.__OAUTH_SCOPE) - LOGGER.info(flow) - credentials = flow.run_console(port=0) - - # Save the credentials for the next run - with open(self.__G_DRIVE_TOKEN_FILE, 'wb') as token: - pickle.dump(credentials, token) - return build('drive', 'v3', credentials=credentials, cache_discovery=False) - else: - return None + if credentials is None or not credentials.valid: + if credentials and credentials.expired and credentials.refresh_token: + credentials.refresh(Request()) + else: + flow = InstalledAppFlow.from_client_secrets_file( + 'credentials.json', self.__OAUTH_SCOPE) + LOGGER.info(flow) + credentials = flow.run_console(port=0) + # Save the credentials for the next run + with open(self.__G_DRIVE_TOKEN_FILE, 'wb') as token: + pickle.dump(credentials, token) + return build('drive', 'v3', credentials=credentials, cache_discovery=False) + return None def edit_telegraph(self):