Which Auth Method Should I Use?
| Use Case | Recommended Method | Why |
|---|---|---|
| Web application with user login | OAuth 2.1 | Secure, user-specific access with token refresh |
| CLI tool or desktop app | API Key or Device Flow | Simple integration, long-lived credentials |
| Server-to-server automation | API Key (via Service Account) | No user interaction needed, easy to rotate |
| Rapid prototyping | No Authentication | Fastest setup, upgrade before production |
| Service-to-service (OAuth) | Client Credentials | Machine-to-machine with scoped tokens |
Quick Decision Guide
- Building a web application? → Use OAuth 2.1 for secure, user-specific access
- Creating a CLI tool or desktop app? → Use an API Key or the Device Flow
- Automating a backend service? → Create a Service Account with an API key
- Rapid prototyping? → Start with no authentication, upgrade before production
- Third-party app integration? → Use OAuth Client Credentials for machine-to-machine
Start with the simplest method that meets your security requirements. You can always upgrade later — for example, moving from API keys to OAuth when you need user-specific access.
Authentication Methods
Sessions
Use case: Web UI, browser-based clients
Duration: Temporary (hours/days)
Setup: Sign in with email/password
API Keys
Use case: Server-to-server, integrations
Duration: Long-lived (months/years)
Setup: Generate in Console, rotate regularly
JWT Tokens
Use case: CLI, headless clients, APIs
Duration: Short-lived (minutes/hours)
Setup: Exchange via OAuth device flow
OAuth 2.1
Use case: Third-party apps, external integrations
Duration: Variable (depends on flow)
Setup: Dynamic client registration
Principal Types
Noorle uses principals to represent entities that can authenticate:User (Human)
Represents a person using Noorle:- Session (sign in to Console)
- JWT token (from OAuth device flow)
- API key (personal, scoped to user)
Service Principal (Machine)
Represents an application, bot, or service:- API key (service-specific, scoped to service account)
- OAuth client credentials (for service-to-service)
Account Roles
Principals have roles within an account (Owner → Admin → Developer → Member):Security Principles
1. Least Privilege
Each principal has minimum permissions needed:2. Scoped Access
API keys are scoped to specific resources/permissions:3. Encryption
All sensitive data encrypted at rest:4. Audit Trail
Every authentication event is logged:Architecture
Choosing Auth Method
| Use Case | Method | Why |
|---|---|---|
| Web UI (Console) | Session | Stateful, cookie-based, familiar |
| API integration | API Key | Long-lived, scoped, rotatable |
| CLI tool | JWT Token | Stateless, temporary, secure |
| Third-party app | OAuth | Standard, user-controlled, revokable |
| Bot/cron job | API Key (service) | Service-specific, auditable |
Migration Between Methods
Typically, you’ll use different methods at different layers:Credential Rotation
All credentials should be rotated: API Keys:Best Practices
Never Share Secrets
API keys are passwords. Treat as secrets. Never commit to version control.
Rotate Regularly
Rotate API keys monthly. Revoke unused credentials. Audit activity.
Scope Appropriately
API key for reading logs? Don’t make it admin. Least privilege always.
Monitor Activity
Check audit logs regularly. Watch for unusual activity. Alert on failures.
Common Patterns
Pattern 1: User + API Key
Developer (you):Pattern 2: Service Account
Bot/cron job:Pattern 3: Third-Party App
External SaaS integration:Troubleshooting
| Problem | Solution |
|---|---|
| API key rejected | Key may be expired. Check creation date. Regenerate if old. |
| Session expired | Automatic. Log in again. Browser will remember. |
| JWT invalid | Token may be expired. Request new token. Check timestamp. |
| 401 Unauthorized | Check auth header format. Verify credentials. Check IP allowlist. |
Next: Explore API Keys for server-to-server authentication.