> 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/ko/data-api/api-overview/oauth-20-authentication.md).

# OAuth 2.0 인증

{% hint style="info" %}
OAuth 2.0은 /ads 엔드포인트에서만 사용할 수 있습니다.

API를 통해 주문 보고를 연동할 때 Basic 인증 및 시크릿 API 키를 사용하여 /orders 엔드포인트를 연동해야 합니다.
{% endhint %}

## 클라이언트 ID 및 클라이언트 시크릿

해당 `client_id` 및 `client_secret` 은(는) 담당 테크니컬 어카운트 매니저가 제공합니다. Client Secret은 보안 사항이므로 공유해서는 안 됩니다.

## 액세스 토큰 요청하기

액세스 토큰을 받으려면 다음을 포함한 요청을 보내야 합니다: `client_id` 및 `client_secret`. 이를 위해 리테일러는 다음 위치로 POST 요청을 보내야 합니다. Epsilon Retail Media Authorization Server 엔드포인트:

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

{% hint style="info" %}
`/oauth2/token` 은(는) 관련 토큰만 제공합니다. 이 토큰을 사용하여 다양한 연동 엔드포인트와 상호 작용하게 됩니다.
{% endhint %}

요청에는 리테일러의 다음 항목이 포함되어 Authorization 요청 헤더를 통해 전송되는 Basic Authorization이 필요합니다. `client_id` 및 `client_secret` base64 인코딩됨:

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

HTTP 요청 본문에 다음 형식을 사용하여 다음 매개변수를 추가해야 합니다. `application/x-www-form-urlencoded` 형식:

`grant_type=client_credentials`

요청은 다음과 같습니다.

```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
```

## 액세스 토큰 받기

응답에는 다음 정보가 포함됩니다.

* `access_token`: 호출할 때 사용할 액세스 토큰입니다. Epsilon Retail Media APIs
* `expires_in`: 액세스 토큰이 만료될 때까지의 시간(초)
* `token_type`: 반환된 토큰의 유형입니다. 이 경우 항상 Bearer입니다.

샘플 응답은 아래와 같습니다.

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

## 토큰 사용하기

다음 항목에 대한 호출 수행 Epsilon Retail Media API 엔드포인트는 요청의 Authorization 헤더에 생성된 액세스 토큰을 추가하기만 하면 됩니다. `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
}
```

## 요청 오류

### Invalid Client

요청 시 전송된 `client_id` or `client_secret` 이(가) 올바르지 않은 경우 다음과 같은 응답을 받게 됩니다.

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

올바른 자격 증명을 사용하고 있는지 확인하세요. `client_id` 및 `client_secret` 을(를) 재확인하고 /token 엔드포인트를 호출할 때 Basic Authorization을 올바르게 사용하고 있는지 확인하세요. ##Invalid Request 요청에 필수 매개변수가 누락되었거나, 잘못된 매개변수 값이 포함되어 있거나, 매개변수가 두 번 이상 포함되어 있거나, 기타 형식이 잘못된 경우 Authorization Server에서 잘못된 요청 오류가 반환됩니다.

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

다음 사항을 확인하세요.

* 만 포함 `grant_type=client_credentials` (요청 본문에)
* 올바른 설정 `Content-Type` (요청 헤더에)


---

# 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/ko/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.
