Authentication
AxonVault uses different authentication methods depending on your integration type. This guide covers both Embedded Wallet SDK authentication and Server Wallet API authentication.Authentication Methods
| Method | Use Case | Integration Type |
|---|---|---|
| JWT Tokens | User-facing applications | Embedded Wallets |
| HMAC-Signed Requests | Backend services | Server Wallets |
Embedded Wallet Authentication
For consumer-facing applications, users authenticate via social login (Google, Apple, Email) and receive JWT tokens. The SDK handles all authentication logic automatically, including:- Social login integration
- Token management and refresh
- Secure token storage
- Error handling and retry logic
Initialize SDK
Authentication Flow
The SDK provides a simpleauthenticate() method that handles all social login complexity:
Token Management
The SDK automatically manages JWT tokens:- Automatic Refresh: Tokens are refreshed before expiration
- Secure Storage: Tokens stored securely (httpOnly cookies in browser)
- Error Handling: Automatic retry on token expiration
Embedded Wallet SDK
See the complete SDK documentation for authentication methods
Server Wallet Authentication
For backend services, use HMAC-SHA256 signed requests with API keys. This ensures request integrity and prevents replay attacks.Credentials
When you create an API key, you receive:| Credential | Description | Example |
|---|---|---|
| Client Key | Public identifier | ak_live_abc123 |
| Secret Key | Private signing key | sk_live_xyz789... |
Request Headers
Every request must include these headers:| Header | Description |
|---|---|
X-Access-Key | Your Client Key |
X-Signature | HMAC-SHA256 signature |
X-Timestamp | ISO 8601 timestamp |
Content-Type | application/json |
Signature Generation
Build the canonical string to sign:| Component | Description | Example |
|---|---|---|
| METHOD | HTTP method (uppercase) | POST |
| PATH | Request path | /v1/server/wallets |
| TIMESTAMP | ISO 8601 timestamp | 2024-01-15T10:30:00Z |
| BODY | JSON request body | {"walletName":"Treasury"} |
Implementation Examples
Request Example
Timestamp Validation
Requests are rejected if the timestamp is:- More than 5 minutes in the past
- In the future
Common Errors
| Error Type | Status | Cause |
|---|---|---|
unauthorized | 401 | Invalid credentials |
signature_mismatch | 401 | Signature doesn’t match |
timestamp_expired | 401 | Timestamp too old |
timestamp_future | 401 | Timestamp in future |
token_expired | 401 | JWT token expired |
Best Practices
Credential Storage
Credential Storage
- Use environment variables or secret managers
- Never hardcode credentials
- Rotate keys regularly (every 90 days)
- Store Secret Keys securely (AWS Secrets Manager, HashiCorp Vault)
Request Security
Request Security
- Always use HTTPS
- Implement request idempotency
- Log requests for audit (exclude signatures)
- Validate timestamp freshness
Error Handling
Error Handling
- Implement retry with exponential backoff
- Handle clock skew gracefully
- Monitor for authentication failures
- Provide user-friendly error messages