Overview
ADK-TS provides a comprehensive authentication system for securing tool access. The auth system supports multiple authentication schemes including API keys, HTTP auth, OAuth2, and OpenID Connect.Authentication Components
The auth system consists of three main components:Auth Schemes
API Key Authentication
Authenticate using API keys in headers, query params, or cookies:packages/adk/src/auth/auth-schemes.ts:28
HTTP Authentication
Support for HTTP auth schemes including Basic, Bearer, and Digest:basic- Username/password encoded in Base64bearer- Bearer tokens (JWT, OAuth2, etc.)digest- Digest access authenticationother- Custom HTTP auth schemes
packages/adk/src/auth/auth-schemes.ts:62
OAuth2 Authentication
Complete OAuth2 flow support:implicit- Implicit grant flowpassword- Resource owner password flowclientCredentials- Client credentials flowauthorizationCode- Authorization code flow (recommended)
packages/adk/src/auth/auth-schemes.ts:116
OpenID Connect
OpenID Connect authentication:packages/adk/src/auth/auth-schemes.ts:143
Auth Configuration
Define how tools should authenticate:packages/adk/src/auth/auth-config.ts:6
Auth Credentials
API Key Credential
packages/adk/src/auth/auth-credential.ts:59
Basic Auth Credential
packages/adk/src/auth/auth-credential.ts:97
Bearer Token Credential
packages/adk/src/auth/auth-credential.ts:137
OAuth2 Credential with Refresh
packages/adk/src/auth/auth-credential.ts:171
Auth Handler
TheAuthHandler orchestrates authentication:
packages/adk/src/auth/auth-handler.ts:7
Tool Authentication
Authenticated Tool
Providing Credentials
Auth Preprocessor
The auth system includes a preprocessor that handles authentication automatically:packages/adk/src/auth/auth-preprocessor.ts
Common Patterns
Environment-Based Credentials
Per-User Credentials
Dynamic Token Refresh
Conditional Authentication
Security Best Practices
Credential Validation
Secure Credential Storage
Testing Authentication
Next Steps
Telemetry
Monitor authentication and agent performance
Tools
Build tools that require authentication