You are developing a command-line interface (CLI) application that will run on Linux servers without a graphical user interface or local web browser. The application must authenticate individual users against Microsoft Entra ID before executing commands. Which MSAL.NET method should you use to perform the authentication?
- AAcquireTokenInteractive
- BAcquireTokenForClient
- AcquireTokenWithDeviceCodeCevap
- DAcquireTokenByUsernamePassword
Cevap
The correct option is AcquireTokenWithDeviceCode, which initiates the Device Code Flow for environments without a local web browser.
The method AcquireTokenWithDeviceCode executes the OAuth 2.0 Device Authorization Grant. This flow provides the user with an verification URL and a code to perform authentication on a separate, browser-equipped device, making it ideal for headless command-line interfaces.
Adım Adım Çözüm
Anahtar Kavram
Microsoft Identity Platform Device Code Flow