You are developing a command-line interface (CLI) tool in C# that developers will run on Linux servers without a graphical user interface (GUI). The CLI tool must authenticate users against Microsoft Entra ID to access a secure downstream API on their behalf. You need to configure the Microsoft Entra ID application registration and implement the token acquisition logic in the C# code. Which two actions should you perform? (Select two.)
- In the Microsoft Entra ID application registration, configure the application as a public client by setting the 'Allow public client flows' option to Yes.Answer
- BIn the C# code, configure the application to use a system-assigned managed identity to authenticate the developer running the tool.
- In the C# code, instantiate the client using PublicClientApplicationBuilder and call AcquireTokenWithDeviceCode.Answer
- DIn the C# code, instantiate the client using ConfidentialClientApplicationBuilder and call AcquireTokenForClient with a client secret.
Answer
To authenticate a user from a headless CLI tool running on Linux, you must enable public client flows in the Entra ID application registration, and implement the token acquisition in C# using PublicClientApplicationBuilder and AcquireTokenWithDeviceCode.
To authenticate a user from a headless CLI tool running on a non-Azure environment, the application must be registered as a public client in Microsoft Entra ID with public client flows enabled. In the C# code, the application should be instantiated using the PublicClientApplicationBuilder, and the token should be acquired using the AcquireTokenWithDeviceCode method. This allows the user to complete authentication on another device that has a web browser.
Step-by-Step Solution
Key Concept
Configuring Microsoft Identity Platform authentication for public client applications running on headless devices using the Device Code Flow.
Estimated Time:1m 30s