You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add auth_config field to FunctionNode that pauses for user
authentication before running. The auth gate lives inside
FunctionNode.run(), keeping _node_runner generic.
Utility functions in _workflow_hitl_utils:
- create_auth_request_event: builds adk_request_credential FC event
with user-facing message
- process_auth_resume: stores credentials with plain value fallback
- has_auth_credential: checks if credentials exist in state
Unwrap {"result":...} for auth responses in _process_resumptions,
consistent with request_input handling.
Includes sample agent and tests for auth flow and credential reuse.
Change-Id: Ib81bf9cf63b8282efd7898def17f6e47a95b2d05
This sample demonstrates how to use `auth_config` on a `FunctionNode` to require user authentication before the node runs.
6
+
7
+
When a node has `auth_config`, the workflow automatically:
8
+
1. Pauses the node and emits an `adk_request_credential` FunctionCall event
9
+
2. The invocation ends — the node is marked as waiting
10
+
3. The client sends a new request with the credential as a FunctionResponse
11
+
4. The workflow stores the credential in session state and re-runs the node
12
+
13
+
The **ADK web UI** (`adk web`) handles step 3 automatically — it recognizes auth
14
+
requests and presents an auth dialog. If you use a custom client, you need to
15
+
handle the `adk_request_credential` FunctionCall and respond with the credential
16
+
yourself.
17
+
18
+
This sample uses **API key** authentication (the simplest credential type).
19
+
20
+
## No External Setup Required
21
+
22
+
This sample uses a mock weather lookup. No external API key or server is needed. When the auth UI prompts for a key, you can enter any value (e.g., `my-test-key-123`).
23
+
24
+
## Sample Inputs
25
+
26
+
Send any message (e.g., `go`) to start the workflow.
27
+
28
+
## Graph
29
+
30
+
```text
31
+
[ START ]
32
+
|
33
+
v
34
+
[fetch_weather] <-- pauses for auth on first run
35
+
|
36
+
v
37
+
[summarize]
38
+
```
39
+
40
+
## How To
41
+
42
+
1. Define an `AuthConfig` with the auth scheme and credential type:
43
+
44
+
```python
45
+
from google.adk.auth.auth_tool import AuthConfig
46
+
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes
0 commit comments