The OAuth Device Flow allows apps to retrieve an OAuth token when the app is not able to show a browser.
This sample demonstrates how to use OAuth Device Code Flow with the Microsoft Graph API. It contains a node app and PostMan Collection to demonstrate the process and API calls needed.
To try out the MS Graph API see the Graph Explorer
This sample reads data from your Microsoft account and in order to use this sample you will first need to register an App in Azure. You can use a free account for this.
To make it easy to view the API requests needed and ensure everything is configured correctly a postman collection is included.
Import the Postman collection file (v2.1) into Postman App. A full guide on how to import can be found on the Postman site.
Edit the collection and navigate to the Variables
tab. Enter the tenantId and clientId and select 'Udpate'. Once this is done you can run each request in the collection in order.
- To run this sample rename
config.sample.json
toconfig.json
- Enter the tenantId and clientId in to the
config.json
- Run
npm install
- Run
npm start
The app will request you enter a device code into the MS website then once complete will display the users name.