IAuthenticationProvider
The core authentication abstraction returns an AzureTokenCredential for a given tenant profile.
Interface
Tenant configuration including auth method, client ID, tenant ID, and cloud environment
Callback to display device code when using
AuthMethod.DeviceCodeCancellation token
Azure Identity credential instance (InteractiveBrowserCredential, DeviceCodeCredential, or ClientSecretCredential)
IAuthenticationProvider.cs:9 for the interface definition.
InteractiveBrowserAuthProvider
The default implementation creates credentials based on theTenantProfile.AuthMethod.
Authentication Methods
- Interactive Browser
- Device Code
- Client Secret
Default flow for desktop applications. Opens the system browser for interactive sign-in.Uses
InteractiveBrowserCredential with:- Redirect URI:
http://localhost:45132(high port for macOS compatibility) - Token cache persisted per tenant profile ID
- Unencrypted cache allowed on Linux where secure storage may be unavailable
InteractiveBrowserAuthProvider.cs:45 for implementation.IntuneGraphClientFactory
Creates authenticatedGraphServiceClient instances configured for the correct cloud environment.
CreateClientAsync
Simplified method that returns just the Graph client.Tenant configuration
Device code callback (only used if
profile.AuthMethod is DeviceCode)Authenticated Microsoft Graph Beta client configured for the tenant’s cloud endpoint
IntuneGraphClientFactory.cs:17 for implementation.
CreateClientWithCredentialAsync
Extended method that returns the Graph client, credential, and scopes for advanced scenarios.Authenticated Graph client
Underlying Azure Identity credential (can be used independently for permission checks)
OAuth scopes used for the client (e.g.,
["https://graph.microsoft.com/.default"])IntuneGraphClientFactory.cs:31 for implementation.
TenantProfile Model
Configuration object for a single tenant connection.Unique identifier for the profile (auto-generated GUID). Used for token cache isolation.
Display name for the profile (e.g., “Production”, “Dev Tenant”)
Azure AD tenant ID (GUID)
Azure AD app registration client ID. Must have appropriate Graph API permissions.
Target cloud environment. Defaults to
CloudEnvironment.Commercial.Authentication method. Defaults to
AuthMethod.Interactive.Client secret (only required when
AuthMethod is ClientSecret)Timestamp of last successful authentication (updated by ProfileService)
TenantProfile.cs:5 for the model definition.
Cloud Environments
CloudEndpoints.GetEndpoints():
| Cloud | Graph Base URL | Authority Host |
|---|---|---|
| Commercial | https://graph.microsoft.com/beta | https://login.microsoftonline.com |
| GCC | https://graph.microsoft.com/beta | https://login.microsoftonline.com |
| GCCHigh | https://graph.microsoft.us/beta | https://login.microsoftonline.us |
| DoD | https://dod-graph.microsoft.us/beta | https://login.microsoftonline.us |
["{rootUrl}/.default"]
See CloudEndpoints.cs:7 for endpoint resolution logic.
Token Caching
Token caches are persisted per profile ID to support multiple tenant connections:- Windows/macOS: Tokens stored in OS credential store (encrypted)
- Linux: Plaintext cache allowed (secure storage often unavailable)
- Cache path: Platform-dependent (MSAL default locations)
InteractiveBrowserAuthProvider.cs:17 for cache configuration.
Required Permissions
The app registration must have delegated or application permissions depending on auth method:Delegated Permissions (Interactive, DeviceCode)
DeviceManagementConfiguration.ReadWrite.AllDeviceManagementApps.ReadWrite.AllDeviceManagementManagedDevices.ReadWrite.AllDeviceManagementServiceConfig.ReadWrite.AllDirectory.Read.AllGroup.Read.AllPolicy.Read.All(for Conditional Access read-only)
Application Permissions (ClientSecret)
- Same as delegated, but with
.Allsuffix - Requires admin consent
docs/GRAPH-PERMISSIONS.md for the complete list and setup script.
Next Steps
Graph Services
Use authenticated clients with Intune services
Cache Service
Cache Graph data to reduce API calls