Skip to content

Commit 9fb5df3

Browse files
authored
Merge pull request #604 from ryantrinh05/master
Updated Google Drive Cred
2 parents 5ac0a6f + b8c7011 commit 9fb5df3

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

hknweb/google_drive_utils.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@ def get_credentials(): # pragma: no cover
2525
"""
2626
SCOPE = ["https://www.googleapis.com/auth/drive"]
2727

28-
json_env = os.getenv("GOOGLE_DRIVE_CREDENTIALS_JSON")
28+
CRED = os.getenv("GOOGLE_DRIVE_SERVICE_ACCOUNT_CREDS")
29+
if not CRED:
30+
raise RuntimeError("Google Drive Service Accounts Creds not found")
2931

30-
if not json_env:
31-
raise ImproperlyConfigured(
32-
"No Drive credentials found in environment variables."
33-
)
34-
35-
try:
36-
info = json.loads(json_env)
37-
except json.JSONDecodeError:
38-
raise ImproperlyConfigured("env doesn't contain a valid JSON")
39-
40-
creds = service_account.Credentials.from_service_account_info(info, scopes=SCOPE)
32+
creds = service_account.Credentials.from_service_account_file(CRED, scopes=SCOPE)
4133

4234
return creds
4335

hknweb/settings/secrets.py.gpg

-838 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)