Skip to content

Commit 8dee90b

Browse files
Shubham Gopaleshubhindia
authored andcommitted
fix drive token generation and update readme
Signed-off-by: shubhindia <shubhindia123@gmail.com>
1 parent 9f60efc commit 8dee90b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Note: You can limit maximum concurrent downloads by changing the value of MAX_CO
7979
- Visit the [Google Cloud Console](https://console.developers.google.com/apis/credentials)
8080
- Go to the OAuth Consent tab, fill it, and save.
8181
- Go to the Credentials tab and click Create Credentials -> OAuth Client ID
82-
- Choose Other and Create.
82+
- Choose `Desktop App` as Application type and Create.
8383
- Use the download button to download your credentials.
8484
- Move that file to the root of mirror-bot, and rename it to credentials.json
8585
- Visit [Google API page](https://console.developers.google.com/apis/library)

generate_drive_token.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
if os.path.exists(__G_DRIVE_TOKEN_FILE):
1010
with open(__G_DRIVE_TOKEN_FILE, 'rb') as f:
1111
credentials = pickle.load(f)
12-
if credentials is None or not credentials.valid:
13-
if credentials and credentials.expired and credentials.refresh_token:
14-
credentials.refresh(Request())
12+
if (
13+
(credentials is None or not credentials.valid)
14+
and credentials
15+
and credentials.expired
16+
and credentials.refresh_token
17+
):
18+
credentials.refresh(Request())
1519
else:
1620
flow = InstalledAppFlow.from_client_secrets_file(
1721
'credentials.json', __OAUTH_SCOPE)
18-
credentials = flow.run_console(port=0)
22+
credentials = flow.run_local_server(port=0)
1923

2024
# Save the credentials for the next run
2125
with open(__G_DRIVE_TOKEN_FILE, 'wb') as token:
22-
pickle.dump(credentials, token)
26+
pickle.dump(credentials, token)

0 commit comments

Comments
 (0)