Using Refresh Token

To obtain a new pair of tokens in case the access token expires or becomes lost, a user sends the HTTP POST request with the refresh token in the request body to the /oauth2/token endpoint. A successfully completed operation returns the 200 response code and a new pair of tokens in the response body.

Tip

If you lose the refresh token, you can log in again under the same user account and get a new pair of tokens.

Using Refresh TokenExample

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

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

  • grant_type — to refresh the token, it is required that the Refresh_token value must be specified for this parameter.
  • refresh_token — the previously saved refresh token.

Request:

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

 

Request Body:

"Username=administrator&Password=Password&refresh_token=eyJhbGciOiJSUzUxMiIsImtpZCI6IkEyNzE5ODUzM0E0MTQyODNCNjMxRjEzRTczMTg4QTRFMDMyREU1QzAiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiIwNzFlYzJkZS03ZDY4LTRkNGEtYjIwZC0yM2Y5MmVjZjAwYmMiLCJ1bmlxdWVfbmFtZSI6IkFkbWluIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2MTMxMjc5OTYsImV4cCI6MTYxNDMzNzU5NiwiaWF0IjoxNjEzMTI3OTk2LCJhdWQiOiJhdXRoL3JlZnJlc2gvOTZlMzE3YmQtOGNkYi00YWFiLTkwMzktNTZhZTY4M2QwMzBjIn0.oCM9aMjv0XySRKug00gLwUarMTrIXnQ8bs5GL8bJ29V8A_DKlqhRz9rLMQsUtBQk35rbAnL4wiww4k7BQLkT50fHZ5VKhdjCPKgN0c_RqflHnHhqiVpoT4vG9ZQKLMziJCZh6LkGu69HxXVlHO79shQnVyn9Vt0ljJFadb-7qP1J65o4XAI-pC3cc6MVqfhdIfMPtSkdGbtJU4ahXsG9qTIMY5Nll-0Y6aD6hinoQ_dFJLkhYknRfqYi_iBjEBntSGjcN-_kM65iWhVHKYCsjdCrfkyjzHYEDPR9386rU6vMV_KEjwbItV7D1Y4tar8D3Ae48rEi5LcHwgwlFSbZjA&grant_type=Refresh_token"

The server sends a response in the following format.

Response:

200

Response Body:

{

 "access_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjUxOUMwRDlFMkRCRTcxQ0E5RkJBOTU3QkJBNENGNEJGMjBCMkM2QzMiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiIzZGE0ZmQzNC03MTY2LTQ2Y2ItOTkxYS01MWE4ZGIxMDVlMjQiLCJuYW1laWQiOiI2ZjQyMzZjMi0xNjI2LTRjZmItOGVlYy00OTYxZTU3YTAyNDEiLCJ1bmlxdWVfbmFtZSI6ImFsZW5rYSIsInJvbGUiOiJQb3J0YWxBZG1pbiIsIm5iZiI6MTYzMzM1OTg0NCwiZXhwIjoxNjMzMzYzNDQ0LCJpYXQiOjE2MzMzNTk4NDQsImF1ZCI6ImFwaS9kZWZhdWx0LzVkMDRjMTc4LWVkYWItNDY0ZS1iNWI3LWRiOTZmOWM5YTk5YiJ9.2WoK8a8iBoF2GFhvpLwrdhOQaWgvYQi-hdWU4Vqn7qtogBrUvbPlswn9QWMBh7Fpmi4GJfQxhiAjHeralXNpF1sLr-43vONApxSTOFbZP0uWEoM1fP36DgDssi2YkD6UAn4eWRrgcqthTSgEteB0QMhqIknT7yfaMMvhLXsvSFLl31DB4nY0T8iPb7rLSXvgQ6VGUe0VYHUqbDRTg2gE0nOAMsJvP8Sy27HO-v2BKBHXJRR_N08AM04RWtnzn1Ttdepv353lT90lrMXBY440TvC4Lu9nCMxXY4Ji6o-8TX1BRSSYazOnV6pHtVrueQ-wfBU6CKHE5a2VcSif_ncDLA",

 "token_type": "bearer",

 "refresh_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjUxOUMwRDlFMkRCRTcxQ0E5RkJBOTU3QkJBNENGNEJGMjBCMkM2QzMiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiIzZGE0ZmQzNC03MTY2LTQ2Y2ItOTkxYS01MWE4ZGIxMDVlMjQiLCJuYW1laWQiOiI2ZjQyMzZjMi0xNjI2LTRjZmItOGVlYy00OTYxZTU3YTAyNDEiLCJ1bmlxdWVfbmFtZSI6ImFsZW5rYSIsInJvbGUiOiJQb3J0YWxBZG1pbiIsIm5iZiI6MTYzMzM1OTg0NCwiZXhwIjoxNjM0NTY5NDQ0LCJpYXQiOjE2MzMzNTk4NDQsImF1ZCI6ImF1dGgvcmVmcmVzaC85YTA0OWRmNi02ZWUxLTRjYzktOThiNy0wZWZkMDA1NjYwN2QifQ.1vgauZwVObWjuQgmARaVJs2OL-8ff-oY-OCatgsLrpFkiZq9ki540RWrmr0cZhFRX_zhDQXsccBETUc1OyKVMPFO-_a0SaCm9UoYE3qe0pySLdc6PySvDhh5A98IO0B-Dq_Kbs3urKEkGUFhNtEiVlr9T4Dnxlmdrc41XhmlzykQj7_gSXqm2hMv3dqF6fYTn-7kVsHP2Hxn9SimFlFHy5Shl-9o_gJySXSAca9WYr4r5kCQJojg8WEJdGy9bpuNK3XKDSe_RmmB8mJm0iJXShpZWoMUi2U2YRowWf4s9h4qs4JbsZLb7pEoSsQpNPKD_Fux37mOYhu2duX36NRC6Q",

 "expires_in": 3600,

 ".issued": "2021-10-04T15:04:04.9299072Z",

 ".expires": "2021-10-04T16:04:04.9259046Z",

 "userId": "6f4236c2-1626-4cfb-8eec-4961e57a0241",

 "username": "administrator",

 "roleName": "PortalAdmin",

 "userType": "Internal",

 "latestNewsShown": true,

 "mfa_enabled": false,

 "shortLived": false

}