use path for gsheet secret

pull/24/head
Cullen Watson 2023-08-28 10:39:27 -05:00
parent 32d96bd3f6
commit 6cff7573b3
2 changed files with 15 additions and 18 deletions

View File

@ -1,12 +1,10 @@
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import csv
from io import StringIO
import gspread
from google.oauth2.service_account import Credentials
from datetime import datetime
from ...jobs import *
from ...scrapers import *
from settings import *
@ -21,15 +19,9 @@ class CSVFormatter:
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive",
]
if not GSHEET_SECRET_JSON:
raise ValueError("GSHEET_SECRET_JSON not provided!")
secret_dict = json.loads(GSHEET_SECRET_JSON)
credentials = Credentials.from_service_account_info(
secret_dict, scopes=scope
credentials = ServiceAccountCredentials.from_json_keyfile_name(
GSHEET_JSON_KEY_PATH, scope
)
gc = gspread.authorize(credentials)
sh = gc.open(GSHEET_NAME)
@ -51,6 +43,11 @@ class CSVFormatter:
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
return f"JobSpy_results_{timestamp}.csv"
@staticmethod
def generate_filename() -> str:
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
return f"JobSpy_results_{timestamp}.csv"
@staticmethod
def format(jobs: CommonResponse) -> StringIO:
"""

View File

@ -2,14 +2,14 @@ from dotenv import load_dotenv
import os
load_dotenv()
# Google sheets output_format
GSHEET_NAME = os.environ.get("GSHEET_NAME", "JobSpy")
GSHEET_SECRET_JSON = os.environ.get("GSHEET_SECRET_JSON")
# gsheets (template to copy at https://docs.google.com/spreadsheets/d/1mOgb-ZGZy_YIhnW9OCqIVvkFwiKFvhMBjNcbakW7BLo/edit?usp=sharing)
GSHEET_JSON_KEY_PATH = "client_secret.json"
GSHEET_NAME = "JobSpy"
# optional auth
# optional autha
AUTH_REQUIRED = False
SUPABASE_URL = os.environ.get("SUPABASE_URL")
SUPABASE_KEY = os.environ.get("SUPABASE_KEY")
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
ACCESS_TOKEN_EXPIRE_MINUTES = 60
ALGORITHM = "HS256"
ALGORITHM = "HS256"