Skip to content

Commit 101d79d

Browse files
Niloth-ptimabbott
authored andcommitted
google-calendar: Fix usage of term "credentials", replace with "tokens".
Replaces some occurrences of the term "credentials" with "tokens" for clarity, to conform with the terms used in Google API documentation. Renamed: - "google-credentials.json" to "google-tokens.json" - `credential_path` to `tokens_path` Google documentation refers to the client secret file sometimes as "credentials.json", and the tokens file as "tokens.json". We have been using "client-secret.json" and "google-credentials.json" respectively, which can be confusing. So, this commit switches to using the term "tokens" instead of "credentials" wherever appropriate, to avoid confusion. The term "credentials" is still used to refer to the Credentials object returned after authorization.
1 parent c01c55b commit 101d79d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

zulip/integrations/google/get-google-credentials

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from google_auth_oauthlib.flow import InstalledAppFlow
88
SCOPES = ["https://www.googleapis.com/auth/calendar.events.readonly"]
99
# File containing user's access and refresh tokens for Google application requests.
1010
# If it does not exist, e.g., first run, it is generated on user authorization.
11-
TOKENS_FILE = "google-credentials.json"
11+
TOKENS_FILE = "google-tokens.json"
1212
# This file contains the information that google uses to figure out which application is requesting
1313
# this client's data.
1414
CLIENT_SECRET_FILE = "client_secret.json" # noqa: S105
@@ -32,10 +32,10 @@ def get_credentials() -> Credentials:
3232
"""
3333

3434
creds = None
35-
credential_path = os.path.join(HOME_DIR, TOKENS_FILE)
35+
tokens_path = os.path.join(HOME_DIR, TOKENS_FILE)
3636

37-
if os.path.exists(credential_path):
38-
creds = Credentials.from_authorized_user_file(credential_path, SCOPES)
37+
if os.path.exists(tokens_path):
38+
creds = Credentials.from_authorized_user_file(tokens_path, SCOPES)
3939
if not creds or not creds.valid:
4040
if creds and creds.expired and creds.refresh_token:
4141
creds.refresh(Request())
@@ -44,7 +44,7 @@ def get_credentials() -> Credentials:
4444
os.path.join(HOME_DIR, CLIENT_SECRET_FILE), SCOPES
4545
)
4646
creds = flow.run_local_server(port=0)
47-
with open(credential_path, "w") as token:
47+
with open(tokens_path, "w") as token:
4848
token.write(creds.to_json())
4949
return creds
5050

zulip/integrations/google/google-calendar

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import zulip
2424
SCOPES = ["https://www.googleapis.com/auth/calendar.events.readonly"]
2525
# File containing user's access and refresh tokens for Google application requests.
2626
# If it does not exist, e.g., first run, it is generated on user authorization.
27-
TOKENS_FILE = "google-credentials.json"
27+
TOKENS_FILE = "google-tokens.json"
2828
CLIENT_SECRET_FILE = "client_secret.json" # noqa: S105
2929
HOME_DIR = os.path.expanduser("~")
3030

@@ -96,8 +96,8 @@ def get_credentials() -> Credentials:
9696
Credentials, the obtained credential.
9797
"""
9898
try:
99-
credential_path = os.path.join(HOME_DIR, TOKENS_FILE)
100-
return Credentials.from_authorized_user_file(credential_path, SCOPES)
99+
tokens_path = os.path.join(HOME_DIR, TOKENS_FILE)
100+
return Credentials.from_authorized_user_file(tokens_path, SCOPES)
101101
except ValueError:
102102
logging.exception("Error while trying to open the %s file.", TOKENS_FILE)
103103
sys.exit(1)

0 commit comments

Comments
 (0)