Skip to main content
A comprehensive guide for validating Scute authentication tokens in your application.

Understanding Scute’s Structure

The Basics

Scute organizes users and permissions in a simple hierarchy:
Example:

Key Concepts

  • Workspace: Your organization’s account on Scute
  • App: Each application you build (mobile app, web app, etc.)
  • App Users: Your end customers who log into your apps
  • Users: Your team members who manage the workspace

JWT Token Structure

When a user successfully authenticates, Scute issues a JWT token with the following structure:

Token Claims Explained

Offline verification is faster and more scalable as it doesn’t require API calls to validate tokens.

Step 1: Get the Public Key

Fetch your app’s public key for JWT verification (this is a public endpoint):
Response Format:

Step 2: Offline JWT Verification

JWKS (JSON Web Key Set) provides automatic key rotation support:

Key Points for Offline Validation

✅ Benefits

  • 🚀 Performance: No API calls required for each validation
  • 🔒 Security: Cryptographically secure verification
  • ⚡ Scalability: No rate limits on token validation
  • 🌐 Offline Support: Works without internet connectivity

⚠️ Important Considerations

  1. Cache Public Keys Wisely
  2. Validate Token Claims
  3. Handle Key Rotation

Online Verification (Alternative)

If you prefer server-side validation or need additional user data, use online verification:

Endpoint

Example Implementation

Online vs Offline Verification

Best Practices

Security Recommendations

  1. Use HTTPS Only: Never transmit tokens over HTTP
  2. Validate Audience: Always check the aid claim matches your app
  3. Check Expiration: Validate exp claim before processing
  4. Store Securely: Use secure storage for tokens on client-side

Performance Optimization

  1. Cache Public Keys: Refresh every 1-6 hours
  2. Use Offline Verification: For high-traffic applications
  3. Connection Pooling: Reuse HTTP connections for online verification
  4. Error Handling: Gracefully handle network failures

Example: Complete Verification Function

Troubleshooting

Common Issues

“Invalid signature” Error
  • Check that you’re using the correct public key for your app
  • Ensure you’re using the RS256 algorithm
  • Verify the token hasn’t been modified
“Token expired” Error
  • Check system clock synchronization
  • Token has a limited lifetime (typically 1 hour)
  • Request a new token using refresh flow
“Invalid audience” Error
  • Ensure the aid claim matches your app ID
  • Token might be intended for a different app
Network Errors (Online Verification)
  • Check API endpoint URL is correct
  • Verify internet connectivity
  • Ensure proper Authorization header format