Last updated: Jun 16, 2026
Token Security
Token Securitylink
Protecting your API tokens is critical for maintaining the security of your Infraspeak integration. This guide covers best practices for token storage, handling, and monitoring.
Security Principleslink
1. Never Expose Tokens in Client-Side Codelink
Tokens should only be used in server-side applications. Never include tokens in:
- JavaScript running in browsers
- Mobile app source code
- Public repositories
- Client-side configuration files
2. Use Environment Variableslink
Store tokens in environment variables, not in source code:
# Set environment variable
export INFRASPEAK_TOKEN="your_token_here"
# Read from environment
import os
token = os.environ.get("INFRASPEAK_TOKEN")
if not token:
raise ValueError("INFRASPEAK_TOKEN environment variable is required")
3. Never Commit Tokens to Version Controllink
Add token files to .gitignore:
# .gitignore
.env
.env.local
.env.*.local
*.key
secrets.json
If you accidentally commit a token:
- Immediately revoke the token in Infraspeak
- Generate a new token
- Remove the token from git history using
git filter-branchor BFG
Incident Responselink
If you suspect a token has been compromised:
Immediate Actionslink
- Revoke the token immediately in Infraspeak
- Generate a new token and update your application
- Review API logs for unauthorized access
- Document the incident for security review
Post-Incidentlink
- Identify how the token was exposed
- Implement controls to prevent recurrence
- Review other tokens that may be at risk
- Update security procedures as needed