mbecchis commited on
Commit
6d70a05
·
verified ·
1 Parent(s): 6b80ad9

Update app1.py

Browse files
Files changed (1) hide show
  1. app1.py +8 -1
app1.py CHANGED
@@ -26,11 +26,18 @@ st.markdown(
26
  unsafe_allow_html=True
27
  )
28
 
 
 
 
 
 
 
 
29
  # Google Sheets connection
30
  @st.cache_data(ttl=300) # Cache for 5 minutes (same as refresh interval)
31
  def load_data():
32
  scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
33
- creds = Credentials.from_service_account_file('FYI-service-account-credentials.json', scopes=scopes)
34
  client = gspread.authorize(creds)
35
 
36
  sheet_id = '1J4YQEf8WvdlS3BjIOya0jsrPHolBEVodSAmhYF9XtSk'
 
26
  unsafe_allow_html=True
27
  )
28
 
29
+ def get_creds():
30
+ raw = os.getenv("GCP_SERVICE_ACCOUNT")
31
+ if raw is None:
32
+ raise ValueError("Missing GCP_CREDENTIALS environment variable.")
33
+ return Credentials.from_service_account_info(json.loads(raw), scopes=SCOPES)
34
+
35
+
36
  # Google Sheets connection
37
  @st.cache_data(ttl=300) # Cache for 5 minutes (same as refresh interval)
38
  def load_data():
39
  scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
40
+ creds = get_creds()
41
  client = gspread.authorize(creds)
42
 
43
  sheet_id = '1J4YQEf8WvdlS3BjIOya0jsrPHolBEVodSAmhYF9XtSk'