Spaces:
Sleeping
Sleeping
Commit ·
fcb850d
1
Parent(s): fe83ebb
Fix refresh_token cookie never actually being written
Browse filesst.rerun() immediately after cookie_manager.set(...) aborted the
script run before the browser could mount the cookie-manager's 'set'
component and run the JS that actually writes document.cookie --
so the encrypted refresh_token never reached the browser, and every
later visit correctly (if uselessly) reported no cookie present.
Removed the rerun; the callback already updates session_state
directly, so the rest of this same run (sidebar, page) already
reflects the fresh access token without needing to restart the script.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -75,7 +75,12 @@ def _handle_drive_oauth_callback(cookie_manager) -> None:
|
|
| 75 |
cookie_token_store.save_refresh_token(cookie_manager, st.user.email, refresh_token)
|
| 76 |
_store_access_token(tokens)
|
| 77 |
st.query_params.clear()
|
| 78 |
-
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
def _ensure_drive_access(cookie_manager) -> None:
|
|
|
|
| 75 |
cookie_token_store.save_refresh_token(cookie_manager, st.user.email, refresh_token)
|
| 76 |
_store_access_token(tokens)
|
| 77 |
st.query_params.clear()
|
| 78 |
+
# Deliberately no st.rerun() here: it would abandon this script run before
|
| 79 |
+
# the browser has a chance to mount the cookie-manager's "set" component
|
| 80 |
+
# and actually execute the JS that writes document.cookie, so the saved
|
| 81 |
+
# refresh_token would never actually reach the browser. Letting this run
|
| 82 |
+
# finish naturally still reflects the fresh access token immediately,
|
| 83 |
+
# since the rest of app.py (sidebar, page) renders right after this call.
|
| 84 |
|
| 85 |
|
| 86 |
def _ensure_drive_access(cookie_manager) -> None:
|