Repository navigation
Labels
core[Component] This issue is related to the core interface and implementation
Description
Configured OAuth2 client-credentials scopes are omitted from the token POST. This grant has no authorization redirect to carry them, so providers can return default permissions or reject the request.
The token POST should include scope=read:items. Actual: grant_type=client_credentials is present, but scope is absent.
Environment: ADK main (2.15.x), Python 3.11.
Offline reproduction (mocked transport/storage; no network access):
"""Offline: capture the actual Authlib client-credentials POST body."""
import asyncio
from urllib.parse import parse_qs
from unittest.mock import patch
from fastapi.openapi.models import OAuth2, OAuthFlows, OAuthFlowClientCredentials
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes, OAuth2Auth
from google.adk.auth.exchanger.oauth2_credential_exchanger import OAuth2CredentialExchanger
from requests import Response
async def main():
scheme = OAuth2(flows=OAuthFlows(clientCredentials=OAuthFlowClientCredentials(
tokenUrl="https://example.invalid/token", scopes={"read:items": "Read items"},
)))
credential = AuthCredential(auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(client_id="client", client_secret="secret"))
bodies = []
def send(session, request, **kwargs):
bodies.append(parse_qs(request.body))
response = Response()
response.status_code = 200
response._content = b'{"access_token":"fresh","token_type":"Bearer","expires_in":3600}'
response.headers["Content-Type"] = "application/json"
return response
with patch("requests.sessions.Session.send", send):
result = await OAuth2CredentialExchanger().exchange(credential, scheme)
print("configured scopes:", sorted(scheme.flows.clientCredentials.scopes))
print("actual grant_type:", bodies[0].get("grant_type"))
print("actual scope:", bodies[0].get("scope"))
print("exchange succeeded:", result.was_exchanged)
assert "scope" not in bodies[0]
asyncio.run(main())Metadata
Metadata
Assignees
Labels
core[Component] This issue is related to the core interface and implementation
Activity
sanketpatil06 commentedon Dec 1, 2026
Hi @sumedh-aerram, we've reproduced this on main.
OAuth2CredentialExchanger._exchange_client_credentials()callsclient.fetch_token()without extracting configured scopes fromOAuth2orOpenIdConnectWithConfigschemes. Your PR #8389 is under review and will be merged once approved.