Getting Device Code

You can obtain a device code from Microsoft Azure to sign in to the Microsoft authentication portal.

Request

POST https://<hostname>:4443/v6/AzureServiceAccounts/DeviceCode

Request Headers

The request header must contain an authorization token of the current session.

Request Body

The request body must contain the following properties:

Property

Type

Description

azureEnvironment

string

Specifies a Microsoft Azure region. The following values are available:

  • Global
  • Germany
  • China
  • Government

azureTenantId

string

Specifies the Microsoft 365 organization ID in Microsoft Azure.

Request Example

Request:

POST https://abc.tech.local:4443/v6/AzureServiceAccounts/DeviceCode

 

Request Header:

Authorization: Bearer <Access-Token>

Request Body:

{

 "azureEnvironment": "Global",

 "azureTenantId": "4468fde5-48b8-4f24-b3f0-ce8a4078ca3f"

}

Response

The server returns the following response to the client.

Response Codes

A successfully completed operation returns a response code 200 OK.

Response Headers

The response to this request contains the following headers. The response may also include additional standard HTTPS headers.

Header

Description

Content-length

The length of the response body.

Content-type

The media type and syntax of the response body message: application/json; charset=utf-8

Response Body

The response body contains the following properties:

Property

Type

Description

userCode

string

Specifies the code that you must copy and then specify on the Microsoft authentication portal.

verificationUri

string

Specifies the verification URL that you must open to sign in to Microsoft Azure.

expiresOnUtc

UTC

Specifies date and time when the code expires.

message

string

Specifies the help message.

Response Example

Response:

200 OK

 

Response Body:

{

  "userCode": "CWE5QHLNM",

  "verificationUrl": "https://microsoft.com/devicelogin",

  "expiresIn": "2022-02-17T22:24:17.128Z",

  "message": "To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code CWE5QHLNM to authenticate."

}