fix: refresh expired OAuth tokens for older chat sessions#5578
fix: refresh expired OAuth tokens for older chat sessions#5578ShivamRIG wants to merge 2 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Testing PlanAdded 3 unit tests in
All 3 tests pass: |
|
Hi @ShivamRIG ,Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
Fixes #5556
Problem:
Old chat sessions retained expired access tokens in session.state.
Tokens were never refreshed, causing tools to fail in older chats.
Reloading the page did not help as the session is server-side.
Fix:
Added _refresh_token_if_expired() method to A2aAgentExecutor.
Called after _prepare_session() in _handle_request(), before
the runner executes. Checks expiry, refreshes using refresh_token,
and updates session state with new access_token and expires_at.
Tests:
Added 3 unit tests covering: