fix
This commit is contained in:
parent
3c08a3ea6b
commit
42113ed497
|
|
@ -580,21 +580,19 @@ class GoogleDriveHelper:
|
||||||
LOGGER.info("Authorize with token.pickle")
|
LOGGER.info("Authorize with token.pickle")
|
||||||
with open(self.__G_DRIVE_TOKEN_FILE, 'rb') as f:
|
with open(self.__G_DRIVE_TOKEN_FILE, 'rb') as f:
|
||||||
credentials = pickle.load(f)
|
credentials = pickle.load(f)
|
||||||
if credentials is None or not credentials.valid:
|
if credentials is None or not credentials.valid:
|
||||||
if credentials and credentials.expired and credentials.refresh_token:
|
if credentials and credentials.expired and credentials.refresh_token:
|
||||||
credentials.refresh(Request())
|
credentials.refresh(Request())
|
||||||
else:
|
else:
|
||||||
flow = InstalledAppFlow.from_client_secrets_file(
|
flow = InstalledAppFlow.from_client_secrets_file(
|
||||||
'credentials.json', self.__OAUTH_SCOPE)
|
'credentials.json', self.__OAUTH_SCOPE)
|
||||||
LOGGER.info(flow)
|
LOGGER.info(flow)
|
||||||
credentials = flow.run_console(port=0)
|
credentials = flow.run_console(port=0)
|
||||||
|
# Save the credentials for the next run
|
||||||
# Save the credentials for the next run
|
with open(self.__G_DRIVE_TOKEN_FILE, 'wb') as token:
|
||||||
with open(self.__G_DRIVE_TOKEN_FILE, 'wb') as token:
|
pickle.dump(credentials, token)
|
||||||
pickle.dump(credentials, token)
|
return build('drive', 'v3', credentials=credentials, cache_discovery=False)
|
||||||
return build('drive', 'v3', credentials=credentials, cache_discovery=False)
|
return None
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def edit_telegraph(self):
|
def edit_telegraph(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue