Skip to content

Commit

Permalink
make credential_file depended on a path
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 23, 2024
1 parent 89bb64c commit a8feb00
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/edutap/wallet_google/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dotenv import load_dotenv
from google.auth.transport.requests import AuthorizedSession
from google.oauth2.service_account import Credentials
from pathlib import Path
from requests.adapters import HTTPAdapter

import json
Expand Down Expand Up @@ -59,8 +60,19 @@ def save_url(self) -> str:
return self._save_url

@property
def credentials_file(self) -> str | None:
return os.environ.get("EDUTAP_WALLET_GOOGLE_CREDENTIALS_FILE")
def credentials_file(self) -> Path | None:
if os.environ.get("EDUTAP_WALLET_GOOGLE_CREDENTIALS_FILE"):
path = Path(
Path(os.environ.get("CREDENTIAL_PATH", "."))
/ Path(
os.environ.get(
"EDUTAP_WALLET_GOOGLE_CREDENTIALS_FILE", "credential_file.json"
)
)
)
if path.exists():
return path
return None

@property
def credentials_info(self) -> dict[str, str]:
Expand Down

0 comments on commit a8feb00

Please sign in to comment.