5-Minute Quickstart
Get ClawAuth running in your project in under 5 minutes. This guide covers both service integration (verifying agents) and agent authentication.
Step 1: Install the SDK
Choose your language:
JavaScript/TypeScript
npm install @clawauth/sdkPython
pip install clawauth-sdkStep 2: Service Integration (Verify Agents)
If you're building a service that needs to authenticate AI agents:
Note: You'll need a ClawAuth service account. Sign up at dashboard.clawauth.comto get your service ID and API key.
JavaScript/Node.js
Service verification
import { ClawAuth } from '@clawauth/sdk';
const auth = new ClawAuth({
serviceId: 'your-service-id',
apiKey: 'your-api-key'
});
// Verify an agent token
const result = await auth.verify(agentToken);
if (result.valid) {
console.log('Agent authenticated:', result.agent.name);
console.log('Trust score:', result.agent.trustScore);
console.log('Permissions:', result.agent.permissions);
} else {
console.log('Authentication failed:', result.error);
}
// Express middleware (automatically adds req.agent)
app.use(auth.middleware());
app.get('/protected', (req, res) => {
if (req.agent) {
res.json({ message: `Hello ${req.agent.name}!` });
} else {
res.status(401).json({ error: 'Authentication required' });
}
});Python
Service verification
from clawauth import ClawAuth
auth = ClawAuth(
service_id="your-service-id",
api_key="your-api-key"
)
# Verify an agent token
result = auth.verify(agent_token)
if result.valid:
print(f"Agent authenticated: {result.agent.name}")
print(f"Trust score: {result.agent.trust_score}")
print(f"Permissions: {result.agent.permissions}")
else:
print(f"Authentication failed: {result.error}")
# Role management
auth.assign_role(agent_id, "admin")
auth.report_trust(agent_id, score=8.5, reason="Good performance")Step 3: Agent Authentication
If you're building an AI agent that needs to authenticate to services:
Generate Keys
Generate ECDSA keypair
import { ClawAuthAgent } from '@clawauth/sdk';
// Generate new keypair
const keypair = ClawAuthAgent.generateKeypair();
console.log('Public key:', keypair.publicKey);
console.log('Private key:', keypair.privateKey);
// Save private key securely
import fs from 'fs';
fs.writeFileSync('agent-key.pem', keypair.privateKey, { mode: 0o600 });Register Agent
Register with ClawAuth
// Register the agent (one-time setup)
const registration = await ClawAuthAgent.register({
email: '[email protected]',
name: 'My AI Agent',
publicKey: keypair.publicKey
});
console.log('Agent registered:', registration.agentId);
// Save this agent ID for authenticationAuthenticate Agent
Get JWT tokens
const agent = new ClawAuthAgent({
agentId: 'your-agent-id',
privateKeyPath: './agent-key.pem'
});
// Get access token
const tokens = await agent.authenticate();
console.log('Access token:', tokens.accessToken);
// Use the token with services
const response = await fetch('https://api.example.com/data', {
headers: {
'Authorization': `Bearer ${tokens.accessToken}`
}
});
// Refresh when needed
const newTokens = await agent.refresh(tokens.refreshToken);Step 4: Test the Integration
Create a simple test to verify everything works:
End-to-end test
// 1. Agent gets token
const agent = new ClawAuthAgent({
agentId: 'test-agent-id',
privateKeyPath: './agent-key.pem'
});
const tokens = await agent.authenticate();
// 2. Service verifies token
const auth = new ClawAuth({
serviceId: 'test-service-id',
apiKey: 'test-api-key'
});
const result = await auth.verify(tokens.accessToken);
if (result.valid) {
console.log('✅ End-to-end test passed!');
console.log('Agent:', result.agent.name);
} else {
console.log('❌ Test failed:', result.error);
}