Getting Device Code

In this article

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

    Request

    POST https://<hostname>:4443/v6/Organizations/{organizationId}/DeviceCode

    Request Headers

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

    Request Parameters

    The following parameter must be specified in the URL of the request:

    Parameter

    Type

    Description

    organizationId

    string

    Specifies the identification number of the Microsoft 365 organization. For more information on how to get this parameter, see Getting Organizations.

    Request Body

    None.

    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.

    verificationUrl

    string

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

    expiresIn

    integer

    Specifies the lifespan of the code in milliseconds.

    message

    string

    Specifies the help message.

    Example

    The example shows how to obtain a device code from Microsoft Azure to sign in to the Microsoft authentication portal.

    Request:

    POST https://abc.tech.local:4443/v6/Organizations/40dfa255-2762-43e5-8320-dff7a9201f90/DeviceCode

     

    Request Header:

    Authorization: Bearer <Access-Token>

     

    Response:

    200 OK

     

    Response Body:

    {

      "userCode": "CWE5QHLNM",

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

      "expiresIn": 899,

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

    }