Overview
Ave supports app-to-app delegation using the Token Exchange grant type defined in RFC 8693. This allows your app to call another app’s API on behalf of a user, enabling secure integration between Ave-connected applications.Use Cases
- Integration platforms - Connect multiple user services
- Data synchronization - Sync user data across apps
- Workflow automation - Trigger actions in other apps
- Background processing - Process user data when user is offline
How It Works
User grants delegation permission
The user authorizes your app to access another app’s API on their behalf. This creates a delegation grant.
Your app exchanges tokens
Your app exchanges its access token for a delegated access token specific to the target app’s API.
Delegation Grant Flow
Step 1: Request Delegation Permission
Build a connector authorization URL to request access to another app’s resource:| Parameter | Type | Description |
|---|---|---|
resource | string | The target app’s resource key |
scope | string | Space-separated scopes to request |
mode | string | user_present or background communication mode |
state | string | CSRF protection token |
user_present- Delegated calls require user to be actively using your appbackground- Delegated calls can happen when user is offline (if target app allows)
Step 2: Handle Callback
After the user grants permission, Ave redirects back with an authorization code:Token Exchange for Delegation
Exchange your access token for a delegated token to call the target app’s API.Endpoint
Request
Response
SDK Usage
Delegated Token Structure
Delegated tokens are always JWTs with the following claims:| Claim | Description |
|---|---|
iss | Issuer (https://aveid.net) |
sub | Identity ID of the user |
aud | Target app’s API audience |
exp | Expiration (10 minutes from issuance) |
iat | Issued at timestamp |
sid | User session/user ID |
cid | Your app’s client ID (source) |
scope | Granted scopes for target resource |
grant_id | Delegation grant ID |
target_resource | Target resource identifier |
com_mode | Communication mode (user_present/background) |
actor | Optional actor claims you provided |
Managing Delegation Grants
List User’s Delegations
Retrieve all delegation grants for the authenticated user:Revoke Delegation Grant
Users can revoke delegation grants at any time:- All delegated tokens issued from this grant are immediately invalid
- Your app can no longer exchange tokens for this resource
- The user must re-authorize to restore access
Security Considerations
Short-lived delegated tokens
Short-lived delegated tokens
Delegated tokens expire after 10 minutes and cannot be refreshed. Your app must exchange tokens each time it needs to call the target API. This limits the window of exposure if a token is compromised.
Audit logging
Audit logging
All delegation operations are logged:
- Grant creation
- Token exchanges
- Grant revocation
Scope validation
Scope validation
Ave validates that:
- Requested scopes are available on the target resource
- Requested scopes don’t exceed the delegation grant’s scopes
- The delegation grant is active (not revoked)
Actor claims
Actor claims
Use the Target APIs can use actor claims for:
actor parameter to include additional context in delegated tokens:- Rate limiting per source app
- Auditing specific user actions
- Debugging and tracing requests
Error Handling
| Error | Description | Resolution |
|---|---|---|
invalid_grant | Subject token is invalid | Ensure you’re using a valid access token |
invalid_target | Resource not found | Verify the resource key is correct |
invalid_scope | Scope not allowed or exceeds grant | Check resource’s available scopes |
access_denied | No delegation grant found | User must authorize delegation first |
invalid_client | Client authentication failed | Verify clientId is correct |
Best Practices
Cache delegated tokens
Delegated tokens are valid for 10 minutes. Cache them to avoid excessive token exchanges:
Request minimal scopes
Only request the scopes your app actually needs. Users are more likely to grant narrow permissions.
Handle revocation gracefully
Delegation grants can be revoked at any time. Handle
access_denied errors by prompting the user to re-authorize:Resource Discovery
Apps can query information about available resources:Get Resource by Key
Next Steps
OAuth Scopes
Learn about standard OAuth scopes
Getting Started
Back to OAuth overview