Skip to content

OAuth Refresh Not Triggered On Token Expiry #3761

@MarlzRana

Description

@MarlzRana

Describe the bug
When using a MCPToolset that requires OAuth and engaging in a long running session, the token expires and causes subsequent calls to an MCP server that requires OAuth to fail.

To Reproduce

  1. Create an agent that requires OAuth i.e:
McpToolset(
            connection_params=StreamableHTTPConnectionParams(
                url=config.MCP_URL
            ),
            auth_scheme=OAuth2(
              flows=OAuthFlows(
                  authorizationCode=OAuthFlowAuthorizationCode(
                      authorizationUrl=config.AUTHORIZATION_SERVER_URL,
                      tokenUrl=config.TOKEN_SERVER_URL,
                      scopes={...},
                  )
            )),
            auth_credential=AuthCredential(
              auth_type=AuthCredentialTypes.OAUTH2,
              oauth2=OAuth2Auth(
                client_id=config.OAUTH_CLIENT_ID,
                client_secret=config.OAUTH_CLIENT_SECRET
               )
           ),
)
  1. Create a session with the agent and complete OAuth such that ones obtains an access token and refresh token
  2. Engage with the agent after the time the access token expires, and one will encounter 401's

Expected behavior
One would expect the token to refresh.

Desktop (please complete the following information):

  • OS: macOS
  • Python version: 3.11.13
  • ADK version: 1.19.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: Gemini 2.5 Flash

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions