> For the complete documentation index, see [llms.txt](https://help.citrusad.com/retail-media-interface/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.citrusad.com/retail-media-interface/integration/sk/data-api/api-overview/oauth-20-authentication.md).

# Autentifikácia OAuth 2.0

{% hint style="info" %}
OAuth 2.0 je k dispozícii iba na koncovom bode /ads

Pri integrácii výkazov objednávok cez API budete musieť integrovať koncový bod /orders s autentifikáciou Basic a vaším tajným kľúčom API.
{% endhint %}

## Client ID a Client Secret

Identifikátor `client_id` a `client_secret` vám poskytne váš Technical Account Manager. Client Secret je súkromný a nemal by sa zdieľať.

## Žiadosť o prístupové tokens

Na získanie Access Token musíte odoslať žiadosť obsahujúcu `client_id` a `client_secret`. Aby to maloobchodník dosiahol, musí odoslať požiadavku POST na Epsilon Retail Media koncový bod Authorization Server:

```http
https://$BASE_URL/v1/oauth2/token
```

{% hint style="info" %}
`/oauth2/token` poskytuje iba príslušný token. Tieto tokeny budete používať na interakciu s rôznymi integračnými koncovými bodmi.
{% endhint %}

Vaša žiadosť bude vyžadovať autorizáciu Basic odoslanú cez hlavičku žiadosti Authorization obsahujúcu údaje maloobchodníka `client_id` a `client_secret` zakódované v base64:

`Authorization: "Basic" + base64encode(client_id + ":" + client_secret)`

V tele požiadavky HTTP budete musieť pridať nasledujúci parameter pomocou formátu `application/x-www-form-urlencoded` :

`grant_type=client_credentials`

Žiadosť bude vyzerať nasledovne:

```http
POST https://$BASE_URL/v1/oauth2/token
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <base64 encoded id+key>
grant_type=client_credentials
```

## Prijatie vášho Access Token

Odpoveď bude obsahovať nasledujúce informácie

* `access_token`: Prístupový token, ktorý sa má použiť pri volaní Epsilon Retail Media API
* `expires_in`: Čas v sekundách, kým uplynie platnosť prístupového tokenu
* `token_type`: Typ vráteného tokenu. V tomto prípade to bude vždy Bearer

Príklad odpovede je uvedený nižšie

```json
{
  "access_token": "xxxxx.yyyyy.zzzzz",
  "expires_in": 3600,
  "token_type": "Bearer"
}
```

## Použitie tokenu

Volania na koncové body Epsilon Retail Media API je možné vykonať jednoduchým pridaním vygenerovaného Access Token do hlavičky Authorization v žiadosti `Authorization: “Bearer “ <access_token>`

```http
POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Bearer <access_token>
{
    "customerId": "wertg5432a",
    "sessionId": "ec9-4e07-881d-3e9",
    "placement": "category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
         ["category:Cupboard/Snacks"]
    ],
    "options": {
                             "filterMode": "AndOr"
                             },
    "maxNumberOfAds": 3
}
```

## Chyby žiadosti

### Neplatný klienta

Ak je `client_id` or `client_secret` odoslaný v žiadosti nesprávny, dostanete takúto odpoveď:

```json
{
  "error": "invalid_client"
}
```

Uistite sa, že používate správne prihlasovacie údaje. Dvakrát skontrolujte svoj `client_id` a `client_secret` a uistite sa, že pri volaní koncového bodu /token používate autorizáciu Basic správne. ##Neplatná žiadosť Ak v žiadosti chýba požadovaný parameter, obsahuje neplatnú hodnotu parametra, obsahuje parameter viac ako raz alebo je inak poškodená, Authorization Server vráti chybu neplatnej žiadosti.

```json
{
  "error": "invalid_request"
}
```

Uistite sa, že:

* Do tela žiadosti zahrniete iba `grant_type=client_credentials` do tela požiadavky
* Nastavíte správne `Content-Type` v hlavičke žiadosti


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.citrusad.com/retail-media-interface/integration/sk/data-api/api-overview/oauth-20-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
