Since users already logged in to your platform, it's convenient to have a way to authorize into the back office with a single press of a button.
Specifically for that, the /api3/account/{id}/impersonate/login method was developed.
Step-by-step guide on setup following this documentation:
1. Firstly, authorize to api3 with your admin credentials using /api3/auth/login method to have a token for further requests. Here's an example of a cURL:
curl -X POST "https://mysite.mlmsoft.cloud/api3/auth/login" \
-H "Content-Type: application/json" \
-d '{
"login": "example@mymail.com",
"password": "123456789",
"networkAccount": false
}'
2. After that, send request for /api3/account/{id}/impersonate/login method, but also add accessToken you get from previous step to the header of a request, otherwise request will be rejected due to incorrect authentication. Also, make sure id of an account is present within address of a method.
Example of a cURL for id 2 is provided below:
curl -X POST "https://mysite.mlmsoft.cloud/api3/account/2/impersonate/login" \
-H "Authorization: Bearer accessToken" \
-H "Content-Type: application/json"
3. And finally, assemble the URL of a back office within HTML button (or any other way you prefer) using newly acquired accessToken, refreshToken and remoteAuthKey.
If a last one is not present within a response of a request, substitute it with "undefined" text.
Here's another example of a complete URL:
https://my-office.mysite.com/#auth(accessToken,refreshToken,remoteAuthKey)
OR
https://my-office.mysite.com/#auth(accessToken,refreshToken,undefined)