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

# OAuth 2.0認証

{% hint style="info" %}
OAuth 2.0 は /ads エンドポイントでのみ利用可能です。

API 経由で注文レポートを統合する際は、基本認証とシークレット API キーを使用して /orders エンドポイントを統合する必要があります。
{% endhint %}

## クライアント ID とクライアントシークレット

その `client_id` と `client_secret` はテクニカルアカウントマネージャーから提供されます。クライアントシークレットは非公開であり、共有しないでください。

## アクセストークンのリクエスト

アクセストークンを取得するには、以下を含むリクエストを送信する必要があります： `client_id` および `client_secret`。そのためには、リテールパートナーは以下へ POST リクエストを行わなければなりません： Epsilon Retail Media 認可サーバーのエンドポイント:

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

{% hint style="info" %}
`/oauth2/token` 関連するトークンのみを提供します。これらのトークンを使用して、さまざまな統合エンドポイントとやり取りします。
{% endhint %}

リクエストには、リテールメディアの以下を含む Authorization リクエストヘッダー経由で送信される Basic 認証が必要です: `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 API
* `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
}
```

## リクエストエラー

### 無効なクライアント

送信された `client_id` or `client_secret` がリクエスト内で正しくない場合、次のようなレスポンスが返されます:

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

正しい資格情報を使用していることを確認してください。 `client_id` および `client_secret` を再度確認し、/token エンドポイントを呼び出すときに Basic Authorization が正しく使用されていることを確認してください。 ##無効なリクエスト リクエストに必須パラメーターが不足しているか、無効なパラメーター値が含まれているか、パラメーターが複数回含まれているか、または形式が正しくない場合、認可サーバーから無効なリクエストエラーが返されます。

```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/ja/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.
