fix: load API bearer token from env var instead of hardcoding (#2)
Closes #2 Removes hardcoded bearer token from db_calls.py and .claude/ops-rework/check_prod_missing_ratings.py. Both files now call load_dotenv() and read PD_API_TOKEN from the environment. The .env file (already gitignored) already contains the PD_API_TOKEN key. Added python-dotenv>=1.0.0 to pyproject.toml dependencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f1ca14791d
commit
548d67ac1f
@ -1,8 +1,13 @@
|
||||
import asyncio
|
||||
import os
|
||||
import aiohttp
|
||||
import pandas as pd
|
||||
|
||||
AUTH_TOKEN = {"Authorization": "Bearer Tp3aO3jhYve5NJF1IqOmJTmk"}
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
AUTH_TOKEN = {"Authorization": f"Bearer {os.environ.get('PD_API_TOKEN', '')}"}
|
||||
PROD_URL = "https://pd.manticorum.com/api"
|
||||
|
||||
|
||||
|
||||
13
db_calls.py
13
db_calls.py
@ -1,10 +1,13 @@
|
||||
import os
|
||||
import aiohttp
|
||||
import pybaseball as pb
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from typing import Literal
|
||||
from exceptions import logger
|
||||
|
||||
AUTH_TOKEN = {"Authorization": "Bearer Tp3aO3jhYve5NJF1IqOmJTmk"}
|
||||
load_dotenv()
|
||||
AUTH_TOKEN = {"Authorization": f"Bearer {os.environ.get('PD_API_TOKEN', '')}"}
|
||||
DB_URL = "https://pd.manticorum.com/api"
|
||||
master_debug = True
|
||||
alt_database = None
|
||||
@ -25,7 +28,7 @@ def param_char(other_params):
|
||||
def get_req_url(
|
||||
endpoint: str, api_ver: int = 2, object_id: int = None, params: list = None
|
||||
):
|
||||
req_url = f'{DB_URL}/v{api_ver}/{endpoint}{"/" if object_id is not None else ""}{object_id if object_id is not None else ""}'
|
||||
req_url = f"{DB_URL}/v{api_ver}/{endpoint}{'/' if object_id is not None else ''}{object_id if object_id is not None else ''}"
|
||||
|
||||
if params:
|
||||
other_params = False
|
||||
@ -39,11 +42,11 @@ def get_req_url(
|
||||
def log_return_value(log_string: str):
|
||||
if master_debug:
|
||||
logger.info(
|
||||
f'return: {log_string[:1200]}{" [ S N I P P E D ]" if len(log_string) > 1200 else ""}\n'
|
||||
f"return: {log_string[:1200]}{' [ S N I P P E D ]' if len(log_string) > 1200 else ''}\n"
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
f'return: {log_string[:1200]}{" [ S N I P P E D ]" if len(log_string) > 1200 else ""}\n'
|
||||
f"return: {log_string[:1200]}{' [ S N I P P E D ]' if len(log_string) > 1200 else ''}\n"
|
||||
)
|
||||
|
||||
|
||||
@ -183,4 +186,4 @@ def get_player_data(
|
||||
def player_desc(this_player) -> str:
|
||||
if this_player["p_name"] in this_player["description"]:
|
||||
return this_player["description"]
|
||||
return f'{this_player["description"]} {this_player["p_name"]}'
|
||||
return f"{this_player['description']} {this_player['p_name']}"
|
||||
|
||||
@ -21,6 +21,8 @@ dependencies = [
|
||||
"pybaseball>=2.2.7",
|
||||
# Validation
|
||||
"pydantic>=2.9.0",
|
||||
# Config
|
||||
"python-dotenv>=1.0.0",
|
||||
# AWS
|
||||
"boto3>=1.35.0",
|
||||
# Scraping
|
||||
|
||||
Loading…
Reference in New Issue
Block a user