Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions hknweb/google_drive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,11 @@ def get_credentials(): # pragma: no cover
"""
SCOPE = ["https://www.googleapis.com/auth/drive"]

json_env = os.getenv("GOOGLE_DRIVE_CREDENTIALS_JSON")
CRED = os.getenv("GOOGLE_DRIVE_SERVICE_ACCOUNT_CREDS")
if not CRED:
raise RuntimeError("Google Drive Service Accounts Creds not found")

if not json_env:
raise ImproperlyConfigured(
"No Drive credentials found in environment variables."
)

try:
info = json.loads(json_env)
except json.JSONDecodeError:
raise ImproperlyConfigured("env doesn't contain a valid JSON")

creds = service_account.Credentials.from_service_account_info(info, scopes=SCOPE)
creds = service_account.Credentials.from_service_account_file(CRED, scopes=SCOPE)

return creds

Expand Down
Binary file modified hknweb/settings/secrets.py.gpg
Binary file not shown.