Update app.py
Browse files
app.py
CHANGED
|
@@ -12,13 +12,14 @@ client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
|
| 12 |
|
| 13 |
# Google Sheets setup
|
| 14 |
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
|
| 15 |
-
|
| 16 |
SPREADSHEET_ID = os.environ.get("GOOGLE_SHEET_ID")
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
)
|
|
|
|
| 22 |
service = build('sheets', 'v4', credentials=credentials)
|
| 23 |
sheet = service.spreadsheets()
|
| 24 |
|
|
|
|
| 12 |
|
| 13 |
# Google Sheets setup
|
| 14 |
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
|
| 15 |
+
SERVICE_ACCOUNT_JSON = os.environ.get("MY_SERVICE_ACCOUNT_JSON")
|
| 16 |
SPREADSHEET_ID = os.environ.get("GOOGLE_SHEET_ID")
|
| 17 |
|
| 18 |
+
if not SERVICE_ACCOUNT_JSON:
|
| 19 |
+
raise ValueError("MY_SERVICE_ACCOUNT_JSON environment variable is not set or empty.")
|
| 20 |
+
|
| 21 |
+
service_account_info = json.loads(SERVICE_ACCOUNT_JSON)
|
| 22 |
+
credentials = Credentials.from_service_account_info(service_account_info, scopes=SCOPES)
|
| 23 |
service = build('sheets', 'v4', credentials=credentials)
|
| 24 |
sheet = service.spreadsheets()
|
| 25 |
|