OAuth 2.0 device authorization grant flow.The expiration time (expires_in) of user_code is 900 seconds,but after 300 seconds, user_code is invalid.
Step 1.Get the usercode, the server returns the data as:
{"user_code":"YZMYLD4K","device_code":"HAQABAAEAAAD--DLA3VO7QrddgJg7Wevr0WV9SxplIjUaZuAytY5xuFmkKNvO1AmBDEPZC-14Pkp2_-TB6vrzmhhe_HLVA_96FQsQaykuxGXBf9F06u44gDTMXjw90rNb4z7jBfvSNTW7-WcLEz15DzL1cDd-WRu3ZKc3yyCH-r4_0JlbzMR1j5WyPIWs_ViNwYUFv3LBi6NFxM9dQum599XdPyTXaIT8PzNzSubzs-DC01agnoT_cWef2Bo7ttF8SV-Idtj1zaRE6lCefIXiaQS1_Ds5RdAPeFOxe2vBvczbI4XAQKE83Z608ZWl-Dy6l6bkoWwXnGBOAja_GiEtm3auJ8rvX0XUw85HxojlCRCsAd5YKXrD3iGuiM0QThl_5yQS0eB4vOc7xhJaHZmv2yWUAxU7miwNIAA","verification_uri":"https://www.microsoft.com/link","expires_in":900,"interval":5,"message":"To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code YZMYLD4K to authenticate."}
Step 2.Get token every 15 seconds
Step 3.After 310 seconds enter the user_code in the browser and log in.The browser displays the result as shown in the picture:
Step 3.The server responds with:
{"error":"authorization_pending","error_description":"AADSTS70016: The provided request has not yet been authorized by the user. The user must input their code.\r\nTrace ID: 21a7ca08-5c6d-4238-a06f-d7808ff27900\r\nCorrelation ID: 55137716-1f7e-42e1-b0fa-4d07b8d4896c\r\nTimestamp: 2022-08-25 09:34:07Z","error_codes":[70016],"timestamp":"2022-08-25 09:34:07Z","trace_id":"21a7ca08-5c6d-4238-a06f-d7808ff27900","correlation_id":"55137716-1f7e-42e1-b0fa-4d07b8d4896c","error_uri":"https://login.microsoftonline.com/error?code=70016"}