OAuth2 Flows
OAuth2 Flows
Comprehensive guides for each supported OAuth2 authentication flow.
Overview
Entra Token CLI supports four OAuth2 authentication flows, each designed for specific scenarios:
| Flow | Best For | User Interaction |
|---|---|---|
| Client Credentials | Service-to-service | None |
| Authorization Code | Web applications | Required |
| Device Code | Limited-input devices | Required (on another device) |
| Interactive Browser | Desktop applications | Required |
Quick Overview
For a quick overview of all flows, see the OAuth2 Flows Core Concept page.
Detailed Guides
Client Credentials Flow
Use for: Automated services, daemons, CI/CD pipelines
Quick example:
| |
Authorization Code Flow
Use for: Web applications with user sign-in
Quick example:
| |
Device Code Flow
Use for: Headless devices, IoT, SSH sessions
Quick example:
| |
Interactive Browser Flow
Use for: Desktop applications, CLI tools with user authentication
Quick example:
| |
Flow Selection
Automatic Inference
The tool automatically selects the appropriate flow based on your profile configuration:
- Client Secret or Certificate configured → Client Credentials flow
- No client secret/certificate → Interactive Browser flow
Manual Override
Override the automatic selection:
| |
Setting Default Flow in Profile
Configure a default flow when creating or editing a profile:
| |
Comparing Flows
By Security Level
- Client Credentials with Certificate - Highest security
- Authorization Code - High security (user context)
- Interactive Browser - Medium-high security
- Device Code - Medium security
By User Experience
- Client Credentials - No user interaction (best for automation)
- Interactive Browser - Simple browser sign-in
- Authorization Code - Browser sign-in with redirect
- Device Code - Sign in on another device (slightly more complex)
By Use Case
Automation & CI/CD:
- ✅ Client Credentials
- ❌ User-interactive flows
Personal Scripts:
- ✅ Interactive Browser
- ✅ Device Code
- ⚠️ Authorization Code (requires web server)
Production Services:
- ✅ Client Credentials with Certificate
- ❌ User-interactive flows
Headless Servers:
- ✅ Device Code
- ✅ Client Credentials
- ❌ Interactive Browser
Troubleshooting
“Flow not supported for this profile”
Cause: Profile configuration doesn’t support the selected flow
Solution:
- For Client Credentials: Ensure client secret or certificate is configured
- For user flows: Ensure delegated permissions are configured
“AADSTS50011: Redirect URI mismatch”
Cause: Redirect URI not configured for Authorization Code or Interactive Browser
Solution:
- Azure Portal → App registrations → Your app → Authentication
- Add redirect URI:
http://localhost:8080
“Device code expired”
Cause: User didn’t authenticate within time limit (typically 15 minutes)
Solution:
- Request new device code
- Authenticate more quickly