Getting Device Code

You can obtain a device code to restore data of Microsoft 365 organizations added using modern app-only authentication.

Request

POST https://<hostname>:4443/v6/RestoreSessions/{restoreSessionId}/organization/restoreDeviceCode

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

restoreSessionId

string

Specifies the identification number of the restore session. For more information on how to get this parameter, see Getting Restore Sessions.

Request Body

The request body must contain the following properties:

Property

Type

Description

targetApplicationId

string

The identification number of the Azure AD application that you want to use for data restore.

targetOrganizationName

string

The name of the Microsoft 365 organization to which you want to restore data.

Note: This parameter is only required when planning to restore to a custom location.

targetRegion

string

Specifies the region of the Microsoft 365 organization that contains data you want to restore. The following values are available:

  • Worldwide
  • Germany
  • China
  • USDefence
  • USGovernment

Note: This parameter is only required when planning to restore to a custom location.

Request Example

Request:

POST https://abc.tech.local:4443/v6/RestoreSessions/2c60fca8-a977-4a4a-9c48-2a3d92ec44e1/organization/restoreDeviceCode

 

Request Header:

Authorization: Bearer <Access-Token>

Request Body:

{

      "targetApplicationId" : "<app_id>",

      "targetOrganizationName" : "abc.onmicrosoft.com",

      "targetRegion" : "Worldwide"

}

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 seconds.

message

string

Specifies the help message.

Response Example

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."

}