---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://yandex.ru/support/retail/ru/ref/authenticationPull.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/support/retail/ru/llms.txt

<div class="openapi">

# ❗️Аутентификация Яндекс Еды в системе Партнёра

<!-- markdownlint-disable-file -->

Для авторизации pull-методов всегда используется OAuth 2.0, без refresh token. Партнёру необходимо настроить схему на своём сервере. Затем требуется передать доступы через менеджера, а именно:

* адрес сервера для отправки запросов (только домен, IP-адреса не поддерживаются);
* client_id;
* client_secret.

Яндекс Еда с полученными доступами запрашивает токен, делая POST-запрос по адресу {host}/security/oauth/token. В параметрах `grant_type` и `scope` передаются значения `client_credentials` и `read write` соответственно.

Ожидаемый заголовок ответа `Content-type: application/json`.

С полученным токеном Еда выполняет следующие запросы, размещая его в заголовке как `Authorization: Bearer token`.

{% cut "Пример запроса" %}
  ```
  curl --location --request POST 'https://test.ru/security/oauth/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'client_id=abv123' \
  --data-urlencode 'client_secret=456vba' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'scope=read write'
  ```
{% endcut %}

{% note info %}

Заголовок Content-type в запросе и ответе отличаются.

{% endnote %}


## Request

<div class="openapi__requests">

<div class="openapi__request__wrapper" style="--method: var(--dc-openapi-methods-post);margin-bottom: 12px">

<div class="openapi__request">

POST {.openapi__method}
```text translate=no
/security/oauth/token
```

</div>

</div>

</div>

<div class="openapi-entity">

### Body

{% cut "application/x-www-form-urlencoded" %}

```json translate=no
{
  "client_id": "987",
  "client_secret": "g8bKdBiIR9MutCObuexDm7nsgkaXU",
  "grant_type": "client_credentials",
  "scope": "read write"
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_client_id_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `987`
{.table-cell}
||
||

_client_secret_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `g8bKdBiIR9MutCObuexDm7nsgkaXU`
{.table-cell}
||
||

_grant_type_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `client_credentials`
{.table-cell}
||
||

_scope_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `read write`
{.table-cell}
||
|#{.json-schema-properties}

</div>

## Responses

<div class="openapi__response__code__200">

## 200 OK

Успешная аутентификация.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "access_token": "CObuexDm7nsgkaXUg8bKdBiIR9Mut",
  "expires_in": 300
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_access_token_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_expires_in_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Время жизни токена в секундах. Дефолтные значения для nomenclature - 5 минут, для orders 1 час.

{.table-cell}
||
|#{.json-schema-properties}

</div>

</div>

<div class="openapi__response__code__400">

## 400 Bad Request

Ошибка в запросе. **В ответе ожидается массив с объектом из списка ошибок**.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
[
  {
    "code": 400,
    "description": "Description of error"
  }
]
```

{% endcut %}

**Type**: [ErrorItem](#entity-ErrorItem)[]

</div>

<div class="openapi-entity">

### ErrorItem {#entity-ErrorItem}

#|
|| **Name** | **Description** ||
||

_code_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: integer

Согласованный с Яндекс Едой числовой код ошибки.
{.table-cell}
||
||

_description_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

Описание ошибки

_Example:_{.json-schema-reset .json-schema-example} `Description of error`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "code": 400,
  "description": "Description of error"
}
```

{% endcut %}

</div>

</div>

<div class="openapi__response__code__500">

## 500 Internal Server Error

Ошибка в запросе. **В ответе ожидается массив с объектом из списка ошибок**.

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
[
  {
    "code": 400,
    "description": "Description of error"
  }
]
```

{% endcut %}

**Type**: [ErrorItem](#entity-ErrorItem)[]

</div>

</div>

</div>

[*Deprecated]: No longer supported, please use an alternative and newer version.