Обменять OAuth-код или обновить токены
POST
/oauth/token
const url = 'https://api.tride.ru/oauth/token';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"grant_type":"authorization_code","client_id":"<идентификатор OAuth-приложения>","client_secret":"<секрет приложения>","code":"<код авторизации>","redirect_uri":"https://service.example.com/callback"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tride.ru/oauth/token \ --header 'Content-Type: application/json' \ --data '{ "grant_type": "authorization_code", "client_id": "<идентификатор OAuth-приложения>", "client_secret": "<секрет приложения>", "code": "<код авторизации>", "redirect_uri": "https://service.example.com/callback" }'Условия доступа описаны в руководстве по OAuth. Порядок подключения.
Request Bodyrequired
Заголовок раздела «Request Bodyrequired»Media typeapplication/json
object
grant_type
required
Тип grant (authorization_code или refresh_token)
string
code
Authorization code (для grant_type=authorization_code)
string
refresh_token
Refresh token (для grant_type=refresh_token)
string
client_id
required
Идентификатор OAuth приложения
string
client_secret
required
Секрет OAuth приложения
string
redirect_uri
Redirect URI (для grant_type=authorization_code)
string
Example
{ "grant_type": "authorization_code", "client_id": "<идентификатор OAuth-приложения>", "client_secret": "<секрет приложения>", "code": "<код авторизации>", "redirect_uri": "https://service.example.com/callback"}Responses
Заголовок раздела «Responses»При ошибке сервер возвращает поле error.
Media typeapplication/json
Any of:
object
access_token
string | null
token_type
string | null
expires_in
integer | null
refresh_token
string | null
scope
string | null
result
boolean
object
error
required
Код или текст ошибки.
string
field
Параметр запроса, если сервер указал его.
string
retry_after
Задержка до следующей попытки в секундах.
integer
Example generated
{ "access_token": "example", "token_type": "example", "expires_in": 1, "refresh_token": "example", "scope": "example", "result": true}