Auth0 Setup Guide
This guide walks you through setting up Auth0 Machine-to-Machine (M2M) authentication for your Bindu agents.Auth0 provides industry-standard OAuth 2.0 / JWT authentication with fine-grained permission control.
Prerequisites
- Auth0 account (free tier available at auth0.com)
- Bindu agent installed and configured
- Basic understanding of OAuth 2.0 and JWT tokens
Auth0 Setup
Step 1: Create Auth0 Account
1
Sign Up
- Go to auth0.com and sign up
- Create a new tenant (e.g.,
your-company) - Your Auth0 domain will be:
your-company.auth0.com
Step 2: Create an API
1
Navigate to APIs
In your Auth0 Dashboard, go to Applications → APIs
2
Create API
Click Create API and fill in:
- Name:
Bindu Agent API - Identifier:
https://api.bindu.ai(this is your audience) - Signing Algorithm:
RS256
The API identifier (audience) can be any URL-like string. It doesn’t need to be a real URL.
Step 3: Define Permissions (Optional)
If you want permission-based access control:1
Go to Permissions Tab
In your API settings, navigate to the Permissions tab
2
Add Permissions
Add the following permissions:
agent:read- Read tasks, contexts, agent infoagent:write- Send messages, create tasksagent:admin- Cancel tasks, clear contexts
Step 4: Create M2M Application
1
Navigate to Applications
Go to Applications → Applications
2
Create Application
Click Create Application and fill in:
- Name:
Bindu M2M Client(or your service name) - Type: Select Machine to Machine Applications
3
Authorize API
- Select your API (
Bindu Agent API) - Select permissions (if using permission-based access)
- Click Authorize
Step 5: Get Credentials
1
Copy Credentials
In your M2M application settings, copy:
- Domain:
your-company.auth0.com - Client ID:
abc123xyz789... - Client Secret:
supersecret...(keep this secure!) - Audience:
https://api.bindu.ai
Agent Configuration
Basic Configuration
Update your agent config to enable authentication:With Permission-Based Access Control
For fine-grained permissions:Configuration Fields
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | Enable/disable authentication |
domain | string | Yes* | Auth0 tenant domain |
audience | string | Yes* | API identifier from Auth0 |
algorithms | array | No | JWT algorithms (default: ["RS256"]) |
issuer | string | No | Token issuer (auto-generated from domain) |
jwks_uri | string | No | JWKS endpoint (auto-generated from domain) |
require_permissions | boolean | No | Enable permission checking (default: false) |
permissions | object | No | Map JSON-RPC methods to required permissions |
enabled: true
Client Implementation
Python Client
Create a client that automatically handles token management:Environment Variables
Create a.env file:
Node.js/TypeScript Client
Testing
1. Start Agent with Auth Disabled
First, test without authentication:2. Enable Auth in Config
Update your config with Auth0 credentials and restart the agent.3. Test Without Token (Should Fail)
4. Get Token from Auth0
access_token from the response.
5. Test With Valid Token (Should Succeed)
Troubleshooting
Error: "Authentication required"
Error: "Authentication required"
Cause: No Authorization header provided or header format is incorrect.Solution:
- Ensure you include the header:
Authorization: Bearer <token> - Check that the token is not empty
- Verify the header format is correct (Bearer prefix with space)
Error: "Invalid token signature"
Error: "Invalid token signature"
Cause: Token signature verification failed.Solution:
- Verify
domainin agent config matches Auth0 tenant domain - Verify
audiencematches the API identifier in Auth0 - Check that you’re using the correct token from Auth0
- Ensure the token hasn’t been modified
Error: "Token has expired"
Error: "Token has expired"
Cause: JWT exp claim has passed.Solution:
- Implement automatic token refresh in your client
- Request a new token from Auth0
- Auth0 M2M tokens typically expire after 24 hours
- Use the token caching pattern shown in client examples
Error: "Invalid audience"
Error: "Invalid audience"
Cause: Token audience doesn’t match agent configuration.Solution:
- Verify
audiencein agent config matches Auth0 API identifier - Check that you’re requesting the token with the correct audience
- Ensure the API is properly configured in Auth0
Error: "Insufficient permissions"
Error: "Insufficient permissions"
Cause: Token lacks required permissions for the operation.Solution:
- Grant required permissions to M2M app in Auth0 dashboard
- Go to Applications → APIs → Your API → Machine to Machine Applications
- Select your M2M app and grant necessary permissions
- Request a new token after granting permissions
Agent Won't Start
Agent Won't Start
Cause: Invalid Auth0 configuration.Solution:
- Check agent logs for specific error messages
- Verify all required fields are present:
domain,audience - Ensure
domainformat is correct (e.g.,tenant.auth0.com) - Test Auth0 connectivity:
curl https://your-domain.auth0.com/.well-known/jwks.json
Security Best Practices
Recommended Practices
- ✅ Environment Variables - Store credentials in environment variables, never in code
- ✅ HTTPS in Production - Always use HTTPS for production deployments
- ✅ Rotate Secrets - Regularly rotate client secrets in Auth0
- ✅ Minimum Permissions - Grant only the permissions needed for each client
- ✅ Monitor Logs - Review Auth0 logs for suspicious activity
- ✅ Token Caching - Cache tokens to reduce Auth0 API calls and improve performance
- ✅ Separate Tenants - Use different Auth0 tenants for dev/staging/production
- ✅ Short-Lived Tokens - Use default token expiration (24 hours)
- ✅ Validate Audience - Always validate the audience claim in tokens
- ✅ Rate Limiting - Implement rate limiting on your agent endpoints
Development vs Production
Development (Localhost):Next Steps
Authentication Overview
Learn about authentication concepts
Azure AD Setup
Configure Azure AD authentication
Client Examples
View complete client implementations
Discord Community
Get help from the community
Additional Resources
- Auth0 Documentation - Official Auth0 guides
- M2M Flow Guide - Client credentials flow
- JWT Debugger - Debug and decode JWT tokens
- GitHub Examples - Complete working examples
- Auth0 Community - Auth0 community forum