Перейти к содержимому

Обменять OAuth-код или обновить токены

POST
/oauth/token
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. Порядок подключения.

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"
}

При ошибке сервер возвращает поле 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

Example generated

{
"access_token": "example",
"token_type": "example",
"expires_in": 1,
"refresh_token": "example",
"scope": "example",
"result": true
}