adk web's "Send Response to Event" popup for OAuth flow with 3rd party application is broken.
Describe the bug When performing Oauth2 on a 3rd party app adk web will correctly open up the Oauth consent link, but adk web has no mechanism to parse the state= and code= URL parameters when the OAuth redirect_uri is set to localhost:8000/dev-ui. It can do this for some Google Workspace apps, like Docs, Sheets, and Calendar, but not for 3rd party apps. The UI will receive the redirect as seen from the logs:
INFO: 127.0.0.1:61648 - "GET /dev-ui?code=[Oauth code is here]&state=[state is here] HTTP/1.1" 200 OK
Instead, adk web will give you a [!] button in the UI. Clicking this leads to a popup:
Send Response To Pending Event
Name
adk_request_credential
Args
{"function_call_id":"adk-1cee9406-eb58-47a0-af85-8f35e4aa6093","auth_config":{"auth_scheme":{"type_":"oauth2","flows":{"authorizationCode":{"scopes":{"read":"read","write":"write"},"authorizationUrl":"https://...
[Resonse text box at bottom]
One would assume the Response text box is looking for function_call_response.response object like:
"function_call_id": "adk-1cee9406-eb58-47a0-af85-8f35e4aa6093",
"auth_config": {
"auth_scheme": {
"type_": "oauth2",
"flows": {
"authorizationCode": {
"scopes": {"read": "read", "write": "write"},
"authorizationUrl": "url",
"tokenUrl": "url"
}
}
},
"raw_auth_credential": {
"auth_type": "oauth2",
"oauth2": {
"client_id": "...",
"client_secret": "...",
"redirect_uri": "http://localhost:8000/dev-ui"
}
},
"exchanged_auth_credential": {
"auth_type": ...
}
}
}
}
However pasting such an object (with the accurate code and state parameters) into the response box leads to:
File "/Users/adk-samples/agents/.venv/lib/python3.12/site-packages/google/adk/auth/auth_preprocessor.py", line 68, in run_async
auth_config = AuthConfig.model_validate(function_call_response.response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/research/adk-samples/agents/.venv/lib/python3.12/site-packages/pydantic/main.py", line 703, in model_validate
return cls.__pydantic_validator__.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for AuthConfig
auth_scheme
Field required [type=missing, input_value={'response': '"{\\"auth_s...3iKf...\\"}}}"'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.11/v/missing
The function_call_response.response object that AuthConfig.model_validate() is trying to validate is a Python dictionary. This dictionary literally looks like this: {"response": "
Can we just make adk web handle OAuth flows directly from http://localhost:8000/dev-ui as the redirect_uri? The FastAPI server already can capture the redirect_uri parameters of code and state. Just have adk web grab these and continue with the Oauth flow the same as it does with the built in Google tool_sets like Gmail, Docs, Calendar, Sheets, etc.
It seems like the workaround right now is to stand up an entire other webserver to capture the redirect_uri's URI parameters and then pass them over to adk but what's the point of this when adk web is capable of handling the capture of the OAuth code and state itself.
Desktop (please complete the following information):
- OS: iOS latest
- Python version(python -V): 3.12
- ADK version(pip show google-adk): 0.5
I think this has been fixed in latest codes. Could you try install from source codes or wait for next release and retry ?
feel free to reopen if it still doesn't work
I confirm that I am able to reproduce the issue on main branch.
Can we just make adk web handle OAuth flows directly from http://localhost:8000/dev-ui as the redirect_uri? The FastAPI server already can capture the redirect_uri parameters of code and state. Just have adk web grab these and continue with the Oauth flow the same as it does with the built in Google tool_sets like Gmail, Docs, Calendar, Sheets, etc.
+1
same issue here.
sent a PR to fix this issue : https://github.com/google/adk-python/pull/1898 please review
could you give an example agent codes that doesn't work with original codes but works with your fix ? and the steps to reproduce.
adk-web should already handle those logic : https://github.com/google/adk-web/blob/508216bafb39d104d551b42330c814ff9dadd58f/src/app/components/chat/chat.component.ts#L616
Hi there, I am having the same issue here.
Python: 3.12.3 google-adk: 1.17.0
I see the PR did not make it and was closed to tidy some things up. Any news on this ?