Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Device Code

Navya Canumalla edited this page May 19, 2018 · 3 revisions

The Device Code flow enables text-only devices to participate in the authentication dance with Azure AD. This is only for devices that don't offer an interactive authentication (web) experience. The principle is that the application will share with the user a code and the URL where the user will sign-in using another device enabling web interaction. Then the application will wait until it gets confirmation from the STS that the user has indeed signed-in, before requesting a token. To use it, the application must call two APIs:

Returns Method
Future<DeviceCode> acquireDeviceCode(String clientId, String resource, AuthenticationCallback<DeviceCode> callback)
Future<AuthenticationResult> acquireTokenByDeviceCode(DeviceCode deviceCode, AuthenticationCallback callback)

The flow is as follows:

  • The application calls AcquireDeviceCode, which interacts with the STS to provide a DeviceCode.

  • The application then displays to the user the content of the Message property of the DeviceCode. This message tells the user to go to a the URL of a web site where s/he will need to provide this code and sign-in with a web enabled device (other than the device running the application as this is a text only device).

  • The application then executes AcquireTokenByDeviceCode which waits until the user has signed-in in the other web enabled device. At this time, the STS will return the token (in the AuthenticationResult)