poemsforaphrodite commited on
Commit
b0ff441
·
verified ·
1 Parent(s): f03ef0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -344,20 +344,27 @@ def main():
344
  if 'auth_flow' not in st.session_state or 'auth_url' not in st.session_state:
345
  st.session_state.auth_flow, st.session_state.auth_url = google_auth(client_config)
346
 
347
- query_params = st.query_params.to_dict()
348
- # Print the query parameters to the console
349
- print(query_params)
350
 
351
- # Display the query parameters in the Streamlit app
352
- st.write("Query Parameters:", query_params['code'][0])
353
 
354
  # Extract the authorization code from query parameters
355
- auth_code = query_params['code'][0] if 'code' in query_params else None
356
- #auth_code = query_params.code if 'code' in query_params else None
357
-
 
 
 
358
  if auth_code and 'credentials' not in st.session_state:
359
- st.session_state.auth_flow.fetch_token(code=auth_code)
360
- st.session_state.credentials = st.session_state.auth_flow.credentials
 
 
 
 
361
 
362
  if 'credentials' not in st.session_state:
363
  show_google_sign_in(st.session_state.auth_url)
@@ -391,7 +398,6 @@ def main():
391
  download_csv_link(st.session_state.report_data)
392
  elif st.session_state.report_data is not None:
393
  st.warning("No data found for the selected criteria.")
394
-
395
 
396
  if __name__ == "__main__":
397
- main()
 
344
  if 'auth_flow' not in st.session_state or 'auth_url' not in st.session_state:
345
  st.session_state.auth_flow, st.session_state.auth_url = google_auth(client_config)
346
 
347
+ # Retrieve query parameters
348
+ query_params = st.experimental_get_query_params()
349
+ print("Query Parameters:", query_params)
350
 
351
+ # Display the query parameters in the Streamlit app for debugging
352
+ st.write("Query Parameters:", query_params)
353
 
354
  # Extract the authorization code from query parameters
355
+ auth_code = query_params.get('code', [None])[0]
356
+ print("Authorization Code:", auth_code)
357
+
358
+ # Display the authorization code in the Streamlit app for debugging
359
+ st.write("Authorization Code:", auth_code)
360
+
361
  if auth_code and 'credentials' not in st.session_state:
362
+ try:
363
+ st.session_state.auth_flow.fetch_token(code=auth_code)
364
+ st.session_state.credentials = st.session_state.auth_flow.credentials
365
+ except Exception as e:
366
+ st.error(f"Error fetching token: {e}")
367
+ print(f"Error fetching token: {e}")
368
 
369
  if 'credentials' not in st.session_state:
370
  show_google_sign_in(st.session_state.auth_url)
 
398
  download_csv_link(st.session_state.report_data)
399
  elif st.session_state.report_data is not None:
400
  st.warning("No data found for the selected criteria.")
 
401
 
402
  if __name__ == "__main__":
403
+ main()