[POST] Обмен кода на токен доступа
Описание запроса
Endpoint: https://{instance}/oauth2/token
Метод: POST
Описание: обменивает код авторизации на токен доступа и обновленный токен.
Ответ на запрос
Положительный ответ
Пример ответа
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5....",
"refresh_token": "8xLnxhdkouixdokzxxcnzxlk...",
"expires_in": 3600,
"token_type": "Bearer"
}
Возможные ошибки
Срок действия авторизационного code истек
В ответе придет ошибка 400 следующего вида:
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Authorization code has expired",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
Решение: с помощью запроса авторизации повторно получить новый code и передать в теле запроса обмена кода на токен доступа.
Пустое значение авторизационного code в теле запроса
В ответе придет ошибка 400 следующего вида:
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Check the `code` parameter",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
Решение: убедитесь, что в теле запроса заполнено значение параметра code, заполните значением, полученным в запросе авторизации.
Указано неверное значение авторизационного code
В ответе придет ошибка 400 следующего вида:
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Cannot decrypt the authorization code",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
Решение: убедитесь, что в теле запроса верно заполнено значение параметра code, заполните значением, полученным в запросе авторизации.
Авторизационный code был отозван сервером и больше не действителен
В ответе придет ошибка 400 следующего вида:
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Authorization code has been revoked",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
Решение: с помощью запроса авторизации повторно получить новый code и передать в теле запроса обмена кода на токен доступа.
Пустое значение client_id в теле запроса
В ответе придет ошибка 401 следующего вида:
{
"error": "invalid_request",
"error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"hint": "Check the `client_id` parameter",
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
}
Неверное значение client_id или client_secret в теле запроса
В ответе придет ошибка 400 следующего вида:
{
"error": "invalid_client",
"error_description": "Client authentication failed",
"message": "Client authentication failed"
}
Решение: убедитесь, что в теле запроса верно заполнены значения параметров client_id / client_secret, полученные у команды разработки Softline ID.