Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 80d1d71

Browse files
authoredJun 29, 2022
Merge pull request #492 from diwash007/token
append os path on json files
2 parents fef72ce + ee66fb3 commit 80d1d71

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

Diff for: ‎docs/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Pull requests are welcome. For major changes, please open an issue first to disc
3939
## Google OAuth
4040
- Go to https://console.cloud.google.com/ and create a new project
4141
- Enable Google Calendar API and create an OAuth 2.0 client ID
42+
- add following on the Authorised redirect URIs of OAuth client ID
43+
```bash
44+
http://localhost/
45+
```
4246
- Download the JSON file and rename it to `credentials.json`
4347
- Move the file to the root folder of the project
4448

Diff for: ‎gsoc/models.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from gsoc.common.utils.tools import build_send_reminder_json
4242

4343
from gsoc.constants import *
44-
from gsoc.settings import PROPOSALS_PATH
44+
from gsoc.settings import BASE_DIR, PROPOSALS_PATH
4545
from settings_local import ADMINS
4646

4747
from google.auth.transport.requests import Request
@@ -59,16 +59,21 @@ def gen_uuid_str():
5959

6060
def getCreds():
6161
creds = None
62-
if os.path.exists('token.json'):
63-
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
62+
if os.path.exists(os.path.join(BASE_DIR, 'token.json')):
63+
creds = Credentials.from_authorized_user_file(
64+
os.path.join(BASE_DIR, 'token.json'),
65+
SCOPES
66+
)
6467
if not creds or not creds.valid:
6568
if creds and creds.expired and creds.refresh_token:
6669
creds.refresh(Request())
6770
else:
6871
flow = InstalledAppFlow.from_client_secrets_file(
69-
'credentials.json', SCOPES)
72+
os.path.join(BASE_DIR, 'credentials.json'),
73+
SCOPES
74+
)
7075
creds = flow.run_local_server(port=0)
71-
with open('token.json', 'w') as token:
76+
with open(os.path.join(BASE_DIR, 'token.json'), 'w') as token:
7277
token.write(creds.to_json())
7378
return creds
7479

0 commit comments

Comments
 (0)
This repository has been archived.