A C# daemon application runs as a Windows Service on an on-premises server. The application must authenticate to the Microsoft Identity Platform without user interaction and query directory metadata from Microsoft Graph. You configure the application registration in Microsoft Entra ID with the Directory.Read.All Application permission, and an administrator grants tenant-wide consent. In your code, you instantiate an IConfidentialClientApplication instance. Which string array should you pass as the scopes argument to the AcquireTokenForClient method to successfully retrieve the access token?
- Anew string[] { "Directory.Read.All" }
- new string[] { "https://graph.microsoft.com/.default" }Cevap
- Cnew string[] { "https://graph.microsoft.com/Directory.Read.All" }
- Dnew string[] { "https://graph.microsoft.com/user_impersonation" }
Cevap
The string array containing 'https://graph.microsoft.com/.default'
For the Client Credentials flow (AcquireTokenForClient), the Microsoft Identity Platform requires the scopes parameter to be the resource root URL followed by '/.default' (e.g., 'https://graph.microsoft.com/.default'). This triggers the token service to inspect the application registration and issue a token containing all application permissions consented to by the administrator. Statically defining and consenting to scopes is mandatory for daemon applications.
Adım Adım Çözüm
Anahtar Kavram
Microsoft Identity Platform Client Credentials flow requires the '/.default' scope pattern to request statically consented application permissions.
Tahmini Süre:1m 30s