Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
348 |
-
|
349 |
-
print(query_params)
|
350 |
|
351 |
-
# Display the query parameters in the Streamlit app
|
352 |
-
st.write("Query Parameters:", query_params
|
353 |
|
354 |
# Extract the authorization code from query parameters
|
355 |
-
auth_code = query_params
|
356 |
-
|
357 |
-
|
|
|
|
|
|
|
358 |
if auth_code and 'credentials' not in st.session_state:
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
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()
|