fix(samples): refresh the access token in the BigQuery MCP sample - #7218
Open
vishal-bulbule wants to merge 1 commit into
Open
vishal-bulbule wants to merge 1 commit into
vishal-bulbule wants to merge 1 commit into
Conversation
The sample fetched an Application Default Credentials token once at import and sent it as a fixed Authorization header, so the toolset stopped working about an hour into a long-running adk web or adk api_server process. Use a header_provider that refreshes the credentials when they are no longer valid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
The
bigquery_mcpsample fetches an Application Default Credentials access token once at importand passes it as a fixed
Authorizationheader. The token expires after about an hour and isnever refreshed, so in a long-running
adk weboradk api_serverprocess the BigQuery toolsstop working until the process restarts. Details in #7217.
Solution:
Replace the fixed header with a
header_providerthat refreshes the credentials when they are nolonger valid and returns the current token. It works on both the mTLS and the regular endpoint
(the session manager's own ADC refresh skips requests that already carry an
Authorizationheader). One file, sample only.
Testing Plan
Unit Tests:
Sample-only change; there are no unit tests for samples.
The one failure is
test_import_loading, which also fails onmainand is fixed by #7214.Manual End-to-End (E2E) Tests:
Ran against the BigQuery MCP server with Application Default Credentials (user credentials), on
mainat d57c84f:Same process, current sample and fixed sample, calling the
list_dataset_idstool before andafter the token expires:
09:13:00 before expiry, fixed sample : OK, list_dataset_ids returned 52 datasets
10:18:17 current sample credentials valid: False
10:18:18 after expiry, current sample : FAILED (tool call rejected)
10:18:20 after expiry, fixed sample : OK, list_dataset_ids returned 52 datasets