SDK Configuration
Configure the AgentSDK with various options to customize behavior, timeouts, callbacks, and more.SDKConfig Interface
Configuration Options
agentId (required)
Your unique agent identifier. This is the client ID used in OAuth flows.
agentSecret (optional)
Agent secret for confidential clients. Only required for initial registration
and some server-side operations. Not needed for OAuth 2.1 with PKCE flows.
serverUrl (optional)
The base URL of the Auth-Agent server. Defaults to the environment variable
AUTH_SERVER_URL or the public Auth-Agent API.timeout (optional)
Request timeout in milliseconds. All API requests will abort after this
duration.
customFetch (optional)
Custom fetch implementation. Useful for testing, adding custom interceptors,
or using a different HTTP client.
onTokensReceived (optional)
Callback invoked when new tokens are received (after OAuth code exchange). Use
this to store tokens in your preferred storage system.
onTokensRefreshed (optional)
Callback invoked when tokens are refreshed. Use this to update stored tokens.
onTokensRevoked (optional)
Callback invoked when tokens are revoked. Use this to clear stored tokens.
Complete Example
Here’s a complete configuration example with all options:Environment Variables
You can use environment variables for sensitive configuration:.env
Best Practices
Store tokens securely
Store tokens securely
Always implement the
onTokensReceived, onTokensRefreshed, and
onTokensRevoked callbacks to properly manage token lifecycle. Use
encrypted storage for sensitive tokens.Use appropriate timeouts
Use appropriate timeouts
Set timeouts based on your network conditions and server response times.
Default is 10 seconds, but you may need longer for slower networks.
Keep secrets secure
Keep secrets secure
Never commit agent secrets to version control. Use environment variables or
secure secret management systems.
Handle errors gracefully
Handle errors gracefully
Implement proper error handling for all SDK methods. Use try-catch blocks
and handle specific error codes.
Next Steps
AgentSDK Methods
Explore all available SDK methods
Token Manager
Learn about token management