Moved google creds to .env

This commit is contained in:
Ojakoo
2022-07-31 16:28:57 +03:00
parent 3f6a719e9d
commit 72e91e3d62
3 changed files with 6 additions and 4 deletions
+1 -2
View File
@@ -11,5 +11,4 @@ node_modules/
.idea/
*.code-workspace
venv/
.venv/
google-service-cred.json
.venv/
+2
View File
@@ -15,6 +15,7 @@ import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sikweb.base import *
from datetime import timedelta
import json
load_dotenv() # loads the configs from .env
@@ -81,6 +82,7 @@ DATABASES = {
# Google api settings
GROUP_KEY = os.getenv("GROUP_KEY", "")
GOOGLE_SERVICE_ACCOUNT = json.loads(os.getenv("GOOGLE_CREDS_JSON", ""))
# JWT authentication
SIMPLE_JWT = {
+3 -2
View File
@@ -24,6 +24,7 @@ from sikweb.settings import (
DEFAULT_EMAIL_FROM_ADDR,
ENABLE_AUTOMATIC_EMAILS,
GROUP_KEY,
GOOGLE_SERVICE_ACCOUNT,
)
from datetime import timedelta
@@ -133,8 +134,8 @@ def add_to_mailinglist(email: str):
# create credentials, with subject is used to impersonate admin account
# jas_manager has groups editor rights in google admin
credentials = service_account.Credentials.from_service_account_file(
filename=SERVICE_ACCOUNT_FILE, scopes=SCOPES
credentials = service_account.Credentials.from_service_account_info(
info=GOOGLE_SERVICE_ACCOUNT, scopes=SCOPES
).with_subject("jas_manager@sahkoinsinoorikilta.fi")
service = build("admin", "directory_v1", credentials=credentials)