Skip to content

Commit

Permalink
fix: adapt get_credentials for filepaths (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna authored Oct 9, 2023
1 parent 77110c3 commit cbbcd14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1 style="width: 100%; padding-top: 32px; margin: 0 0 16px; border-top: 1px sol
">Redefinir minha senha</a>

<span style="display: block; width: 100%; margin: 32px 0; border-top: 1px solid #DEDFE0;"></span>

<div style="display: block; width: 100%; margin: 0 auto;">
<p style="color: #6F6F6F; text-align: center; font-family: Arial; font-size: 13px; font-weight: 400; line-height: 18px; letter-spacing: 0.2px; margin: 0;">
Se você não fez essa solicitação, ignore este e-mail. A sua senha atual continuará válida e segura. Caso tenha alguma dúvida ou precise de suporte, entre em contato através do e-mail
Expand Down
13 changes: 10 additions & 3 deletions basedosdados_api/api/v1/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import json
from json import loads
from pathlib import Path
from time import sleep

from django import forms
Expand Down Expand Up @@ -216,8 +217,14 @@ class CoverageTableInline(admin.StackedInline):

def get_credentials():
"""Get google cloud credentials"""
credentials_dict = json.loads(settings.GOOGLE_APPLICATION_CREDENTIALS)
credentials = service_account.Credentials.from_service_account_info(credentials_dict)
creds_env = settings.GOOGLE_APPLICATION_CREDENTIALS
try:
creds_path = Path(creds_env)
assert creds_path.is_absolute() or creds_path.is_relative_to(".")
credentials = service_account.Credentials.from_service_account_file(creds_path)
except (TypeError, ValueError):
credentials_dict = loads(creds_env)
credentials = service_account.Credentials.from_service_account_info(credentials_dict)
return credentials


Expand Down
3 changes: 3 additions & 0 deletions basedosdados_api/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@

# Logging
setup_logger(level="DEBUG", serialize=False)

# Google Application Credentials
GOOGLE_APPLICATION_CREDENTIALS = getenv("GOOGLE_APPLICATION_CREDENTIALS", "")

0 comments on commit cbbcd14

Please sign in to comment.