Secure credential storage and best practices for the Nylas CLI.
Quick Links: README | Commands | Development
nylas auth config # Configure API credentials (stored securely)Credentials are stored in the system keyring under service name "nylas":
| Key | Constant | Description |
|---|---|---|
client_id |
ports.KeyClientID |
Nylas Application/Client ID |
api_key |
ports.KeyAPIKey |
Nylas API key (Bearer auth) |
client_secret |
ports.KeyClientSecret |
Provider OAuth secret (Google/Microsoft) |
org_id |
ports.KeyOrgID |
Nylas Organization ID |
grants |
grantsKey |
JSON array of grant info (ID, email, provider) |
default_grant |
defaultGrantKey |
Default grant ID for CLI operations |
grant_token_<id> |
ports.GrantTokenKey() |
Per-grant access tokens |
| File | Purpose |
|---|---|
internal/ports/secrets.go |
Key constants (KeyClientID, KeyAPIKey, etc.) |
internal/adapters/keyring/keyring.go |
System keyring implementation |
internal/adapters/keyring/grants.go |
Grant storage (grants, default_grant) |
internal/app/auth/config.go |
SetupConfig() saves credentials to keyring |
- macOS: Keychain
- Linux: Secret Service (GNOME Keyring/KWallet)
- Windows: Credential Manager
- Fallback: Encrypted file store (
~/.config/nylas/)
NYLAS_DISABLE_KEYRING=true # Force encrypted file store (useful for testing/CI)Non-sensitive settings stored in ~/.config/nylas/config.yaml:
- Region (us/eu)
- Callback port
# Set credentials for integration tests
export NYLAS_API_KEY="your-api-key"
export NYLAS_GRANT_ID="your-grant-id"
# Run tests
make ci-full # Complete CI pipeline with tests and cleanupThe .gitignore blocks these patterns to prevent credential commits:
Environment & Credentials:
.env,.env.*,*.envcredentials.json,credentials.yaml,*credentials*secrets.json,secrets.yaml,*secrets*
Keys & Tokens:
*.key,*.pem,*.p12,*.pfxapi_key*,*token*,oauth_token*id_rsa*,id_dsa*,*.gpg
make security # Run before commitsChecks:
- No hardcoded API keys (
nyk_v0pattern) - No credential logging
- No sensitive files staged
Users:
- Never commit credentials
- Use
--yesflag carefully (skips confirmations) - Rotate API keys regularly
Developers:
- Run
make securitybefore commits - Never log credentials
- Validate all user input
Detailed guide: See docs/security/practices.md for network security, input validation, and OWASP compliance details.