Requesting Authorization

The Veeam Backup for Microsoft Azure REST API accepts several grant types to authenticate a Veeam Backup for Microsoft Azure user:

Using Password Grant Type

To obtain authorization tokens, a user sends the HTTP POST request to the /api/oauth2/token endpoint.

The request body must contain the grant_type parameter with the specified Password value and the credentials of a user created in Veeam Backup for Microsoft Azure. For more information on how to create users, see Backup Administrator Accounts or the Veeam Backup for Microsoft Azure User Guide, section Managing Backup Administrator Accounts.

A successfully completed operation returns the 200 response code. In the response body, Veeam Backup for Microsoft Azure returns an access token, its expiration time (in seconds) and a refresh token. The user inserts the access token in headers of further requests to the Veeam Backup for Microsoft Azure REST API. The refresh token must be saved locally.

To learn how to authorize your access using the Password grant type, see Example [Password]. Alternatively, you can use the Swagger UI.

Using MFA Grant Type

Note

MFA is disabled by default. To learn how to enable MFA, see Multi-Factor Authentication or the Veeam Backup for Microsoft Azure User Guide, section Managing Backup Administrator Accounts.

If multi-factor authentication (MFA) is enabled for a user, the user must first obtain an mfa token, and then get authorization tokens.

  1. To obtain an mfa token, the user sends the HTTP POST request to the api/oauth2/token endpoint. The request body must contain the grant_type parameter with the specified Password value and the credentials of the user.

A successfully completed operation returns the 200 response code. In the response body, Veeam Backup for Microsoft Azure returns an mfa token.

  1. To obtain an access token and a refresh token, the user must send another HTTP POST request to the api/v2/token endpoint. The request body must contain the grant_type parameter with the specified Mfa value, the mfa token previously received from the authorization server, and the verification code generated by an authentication application on the trusted device.

A successfully completed operation returns the 200 response code. In the response body, Veeam Backup for Microsoft Azure returns an access token, its expiration time (in seconds) and a refresh token. The user inserts the access token in headers of further requests to the Veeam Backup for Microsoft Azure REST API. The refresh token must be saved locally.

To learn how to authorize your access using the MFA grant type, see Example [MFA]. Alternatively, you can use the Swagger UI.

Requesting AuthorizationExample [Password]

To obtain an access token and a refresh token, a user sends the HTTP POST request to the api/oauth2/token endpoint.

In the request body, the user specifies the following parameters:

  • grant_type — the Password value must be specified for this parameter.
  • Username and Password — credentials used to access the server; in this example, administrator and Password1 are used.

Request:

POST https://51.11.247.127/api/oauth2/token

Request Header:

Content-Type: application/x-www-form-urlencoded

 

Request Body:

Username=administrator&Password=Password1&grant_type=Password

The server sends a response in the following format.

Response:

200

Response Body:

{

 "access_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjQ2MDU0QjExNTE3Njk0QzAxN0IyRTE2MTQyNURCRDM1QkNGNzY3NkQiLCJ0eXAiOiJKV1QifQ.eyJ1bmlxdWVfbmFtZSI6InVzZXIiLCJuYmYiOjE1ODYyNTUzNzksImV4cCI6MTU4NjI1NjI3OSwiaWF0IjoxNTg2MjU1Mzc5LCJhdWQiOiJhY2Nlc3MifQ.kOCwrbf6BErst5X-ZOK5zSVH9htMN5GJpPkE1MScDM08iHrF4vPZaGGlHGZzvLu6eJmzyM-GA9zG5QAoPQcQCxzhUf4btj6JvUd1thz3BgfSfCvDh_nQUG-WQ5dAkeOL8M7sze6nlHRDJDg1b7D2Ev7BsFg41ip24drWl2wyebZVZXBOwpIsD7rbX1fJW3FHfvEMyes7h8gWruHtqc-6uJnMuA7YJc706rlXHf6wgpLJAaW2qRAwtBUpE6kib9odU58Hc2aS5QqQBwwKX6hTI3ZbBDg_B5KW6xL7rRIMbtTgdEhbDn41WMPhINS9yAFf7sKvdsofStPX31H0Mt1eOg",

 "token_type": "bearer",

 "refresh_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjQ2MDU0QjExNTE3Njk0QzAxN0IyRTE2MTQyNURCRDM1QkNGNzY3NkQiLCJ0eXAiOiJKV1QifQ.eyJ1bmlxdWVfbmFtZSI6InVzZXIiLCJ0b2tlbl9pZCI6ImQ5ZDhiN2RlLWIwYjUtNDc1Yi04ZTE4LTU4ZGMzMzVmOWIzNSIsInNob3J0X3Rlcm1fZXhwaXJhdGlvbiI6IkZhbHNlIiwibmJmIjoxNTg2MjU1Mzc5LCJleHAiOjE1ODc0NjQ5NzksImlhdCI6MTU4NjI1NTM3OSwiYXVkIjoicmVmcmVzaCJ9.1R2vkCTmAx28mBg21vq61SYTzZN-wCLyG8SjL3iMofuhUKeZ2oRMNlOSTqZ7v-FxvMTXMIVXBw9WRDIjxMzr182K9E26UcblcUa0Gp8o0fNeCKF_pN0WwYx77Ewzedl9bUmY5rlseOjTU-dQNp-G51mGfn4dU4pEaCxFkX9NCGuJqr4Q9NedoyGXNW6PuAm8gwQnOQjLPWmCzkpaBGZMda41osPyq1bKIL6Be7cen1StTKjiU86OzM1sjIOgG3-hZnfKW5ZyO_fLb-nLeRrOuR65f9peJE3WgVFrmWm0MAtxvPCAq99Nutek2ssI2byNzxc1-hOeD-oZrwm-725G8g",

 "expires_in": 3600,

 ".issued": "2020-06-10T10:29:39",

 ".expires": "2020-06-10T10:44:39",

 "username": "administrator",

 "roleName": "Administrator",

 "mfa_enabled": false

}

Requesting AuthorizationExample [MFA]

To access the REST API when MFA is enabled, a user must do the following:

  1. To obtain an mfa token, the user sends the HTTP POST request to the api/oauth2/token endpoint.

In the request body, the user specifies the following parameters:

  • grant_type — the Password value must be specified for this parameter.
  • Username and Password — credentials used to access the server; in this example, administrator and Password1 are used.

Request:

POST https://51.11.247.127/api/oauth2/token

 

Request Body:

Username=administrator&Password=Password1&grant_type=Password

The server sends a response in the following format.

Response:

200

Response Body:

{

 "token_type": "bearer",

 "expires_in": 0,

 ".issued": "0001-01-01T00:00:00",

 ".expires": "0001-01-01T00:00:00",

 "username": "administrator",

 "roleName": "Administrator",

 "mfa_enabled": true,

 "mfa_token": "MTNCNzVFRjY1RDI2MTFBODE1Q0U1NzgyRENERTk1RTYzNTAwMDBBRkJGODVFNkZBNzFBM0FBMzE5M0Q4OEM5RQ=="

}

  1. To obtain an access token and a refresh token, the user sends the HTTP POST request to the api/oauth2/token endpoint.

In the request body, the user specifies the following parameters:

  • grant_type — the Mfa value must be specified for this parameter.
  • mfa_token — the mfa token previously received from the authorization server.
  • mfa_code — the six-digit verification code generated on the trusted device.

Request:

POST https://51.11.247.127/api/oauth2/token

 

Request Body:

grant_type=Mfa&mfa_token=NkZFMzc4RjA4NzJCQzk1QjU3NTY1Mzc2RTU1MjVCODkzOThDQjdGODMzNDVDMEY0QUZGRTIzMjZFQTNDQ0QxRg==&mfa_code=346816

The server sends a response in the following format.

Response:

200

Response Body:

{

 "access_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjcxMDhGMUZCMTIyODBBOEE5ODQzQzY1NTU5NjJFNDU5NTEzNUYyREMiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiJkMGY1YmViMi0zMDAwLTQyOWEtOTE1Ni1kYzYyN2Q2ZmI1MGQiLCJ1bmlxdWVfbmFtZSI6ImFsZW5hIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2MDY5MDg4NDMsImV4cCI6MTYwNjkxMjQ0MywiaWF0IjoxNjA2OTA4ODQzLCJhdWQiOiJhcGkvZGVmYXVsdC9mMTQ0NDYyNS1mMGIwLTQ5OTctOTEzOC01MDUzNmQ4YTE3NGIifQ.LnPtqwl57_3oxlfYSGqHwGQcR6lO7J35Trs8BM9Q-R3DkH4L2rFTfykBtpwLl-wmkyLzfjFtVEPxt6Jpr5lqWk1wh0djEaJfml6AWuqjhoIlILOWjPThWrkhoRItMYpZyTydimZdURzZ4ynW54vSaItOVNbmD5BdCSHfGirCeHnhzlv-FjR3vszDmcKAKpEFPgFhKry7peTxJcBhhVoiDMDFsFEKRIQWF5sDuHDkSrESOUS70quO85ITkv_upzFLzyGA7EFNM9Gfp4hQfAAdWt8NlQw-zET4aGsEGt-GNr6K-YFwKHq43KdpDdmsOv8diF19YtIOfCWfz39z5hWCFw",

 "token_type": "bearer",

 "refresh_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjcxMDhGMUZCMTIyODBBOEE5ODQzQzY1NTU5NjJFNDU5NTEzNUYyREMiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiJkMGY1YmViMi0zMDAwLTQyOWEtOTE1Ni1kYzYyN2Q2ZmI1MGQiLCJ1bmlxdWVfbmFtZSI6ImFsZW5hIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2MDY5MDg4NDMsImV4cCI6MTYwODExODQ0MywiaWF0IjoxNjA2OTA4ODQzLCJhdWQiOiJhdXRoL3JlZnJlc2gvYjVjYzJjZjItMjY2Ny00ZDRmLWE3OGItYzg1ZWZmMWM0ZDI1In0.Ld-SN7KHc2d9FLploxR9vobCqHA78UkA0MfhzqyGaGNkFk4U2XmV7_H8edhfZ5AczZuovwvTXDfmpPpbKhw3JXenyep9aBvwvc4D3Ek2bS2Mm1HQ71R5S7Pq2kBm7G_9dNq5pKVcW6AQxOcKhk4taxNZFcwrWSiM9Xva3GyGJxncFUil0QOO3on9Y8d7Z0e4utJtAt3j5qNY6SR6DfqLCF0CKdYINaIgKIB9vmxijIcd_CM3ATFO54VxeBCClchQqUCa8cfYWq3OxkFYaOZMEFIugnKL3fD0Io9S7asL3jTxl2q2z4VDMGhSJee2hXak68ajlbKSsD43p1LKDtesHA",

 "expires_in": 3600,

 ".issued": "2020-12-02T11:34:03.3605646Z",

 ".expires": "2020-12-02T12:34:03.3575256Z",

 "username": "administrator",

 "roleName": "Administrator",

 "mfa_enabled": false

}

I want to report a typo

There is a misspelling right here:

 

I want to let the Veeam Documentation Team know about that.