Authentication

Edit on GitHub

Authentication and authorization of operations via Azion API is done through Tokens.

The first step is to create the Token through authenticating a user registered in Real-Time Manager.

  1. How to encode Username and Password in Base64
  2. Creating a Token
  3. Cancelling a Token

1. How to encode Username and Password in Base64

Only token creation and cancelling operations are performed through Basic Authentication, that is, with a username and password. You can create and cancel the token through the API itself, but for that you need to encode your username and password in base64.

Base64 encoding can be done from the command line on a Unix terminal:

$ echo 'user@domain:password'|base64
dXNlckBkb21haW46cGFzc3dvcmQK

If you do not have a Unix terminal available, you can use the free online service at https://www.base64encode.org/


2. Creating a Token

POST /tokens

Parameter Description Type of Parameter Type of Data
Authorization (required) Basic authentication for creating the Token takes place via the “user@ domain: password” pair encoded in base64, sent in the HTTP request via the header “Authorization: Basic ”.

For example, if the user is “user@domain” and the password is “password” the base64 encoding resulting from the string “user@domain: password” will be “dXNlckBkb21haW46cGFzc3dvcmQK” and the header to be sent will be:

e.g.:

Authorization:
Basic
dXNlckBkb21haW46cGFzc3dvcmQK
header string

Request Example

POST /tokens 
Accept: application/json; version=3
Content-Type: application/json
Authorization: Basic dXNlckBkb21haW46cGFzc3dvcmQK

Answer Example

{
    "token": "3a110f2990cfbce7b84265cc027f992acb9743eb",
    "created_at": "2019-04-01 13:53:28.536782+00:00",
    "expires_at": "2019-04-02 13:53:28.536782+00:00"
}

3. Cancelling a Token

DELETE /tokens/:token

Parameter Description Type of Parameter Type of Data
Authorization (required) Basic authentication for cancelling the Token takes place via the “user@ domain: password” pair encoded in base64, sent in the HTTP request via the heading “Authorization: Basic ”.

For example, if the user is “user@domain” and the password is “password” the base64 encoding resulting from the string “user@domain: password” will be “dXNlckBkb21haW46cGFzc3dvcmQK” and the header to be sent will be:

e.g.:

Authorization:
Basic
dXNlckBkb21haW46cGFzc3dvcmQK
header string
:token (required) Token to be deleted path string

Request Example

DELETE /tokens/3a110f2990cfbce7b84265cc027f992acb9743eb
Accept: application/json; version=3
Content-Type: application/json
Authorization: Basic dXNlckBkb21haW46cGFzc3dvcmQK

Answer Example

HTTP/2 204

Didn’t find what you were looking for? Open a ticket.