---
title: "Experience Edge API用のJSONウェブトークンを作成します"
slug: "create-a-json-web-token-for-experience-edge-apis"
abstract: "Experience Edge API用のJSONウェブトークン(JWT)を作成します。"
---
# Experience Edge API用のJSONウェブトークンを作成します

JSONウェブトークン(JWT)の作成は、管理者REST APIおよびトークンREST APIへのリクエスト [を承認](https://doc.sitecore.com/sai/ja/developers/sitecoreai/experience-edge/experience-edge-apis/authorization-and-api-access.html "Authorization and API access") する際に必須であり、プログラム的にデリバリー GraphQL APIトークンを作成することも可能です。Delivery GraphQL APIのトークンAPIを作成する推奨方法は、SitecoreAI Deployで直接生成することです。

> !注また、[オーサリング&マネジメントAPIやデプロイREST API用のJWTを作成する](https://doc.sitecore.com/sai/ja/developers/sitecoreai/deploying-sitecoreai/deploy-app/managing-sitecoreai-client-credentials/create-a-json-web-token-for-the-authoring-and-management-api-or-the-deploy-api.html)こともできます。

## JSONウェブトークンを作成してください

> !注**始める前に**
> 
> -   [SitecoreAI Deployで環境用のエッジ管理クライアントを作成します。これによりクライアントIDとクライアントシークレットが生成されます。JWTを作成する際にはクライアントIDとクライアントシークレットを使用します。](https://doc.sitecore.com/sai/ja/developers/sitecoreai/deploying-sitecoreai/deploy-app/managing-sitecoreai-client-credentials/manage-client-credentials-for-a-sitecoreai-organization-or-environment.html#create-an-edge-administration-client-for-an-environment)

JSONウェブトークン(JWT)を要求するには、JSONまたはURLエンコード形式のいずれかで以下のHTTPリクエストを行います。

POST https://auth.sitecorecloud.io/oauth/token

リクエスト文には以下の必要な属性を記載する必要があります:

属性

種類

概要

価値

audience

ストリング

JWTが対象とするAPI群。

https://api.sitecorecloud.io

grant\_type

ストリング

JWTを得るために用いられた方法です。

client\_credentials

client\_id

ストリング

あなたのEdge管理クライアントのクライアントID。  
  
この価値が分からない場合は、まず [環境用のエッジ管理クライアントを作成し](https://doc.sitecore.com/sai/ja/developers/sitecoreai/deploying-sitecoreai/deploy-app/managing-sitecoreai-client-credentials/manage-client-credentials-for-a-sitecoreai-organization-or-environment.html#create-an-edge-administration-client-for-an-environment)ましょう。

あなたのクライアントID。  
  
例: or27P5db...

client\_secret

ストリング

あなたのEdge管理クライアントのクライアント秘密です。  
  
この価値が分からない場合は、まず [環境用のエッジ管理クライアントを作成し](https://doc.sitecore.com/sai/ja/developers/sitecoreai/deploying-sitecoreai/deploy-app/managing-sitecoreai-client-credentials/manage-client-credentials-for-a-sitecoreai-organization-or-environment.html#create-an-edge-administration-client-for-an-environment)ましょう。

あなたのクライアントの秘密です。  
  
例: ctrWEP7Rd3...

::::tabs:::tab{title="JSON"}

curl -X POST 'https://auth.sitecorecloud.io/oauth/token' \\
-H 'Content-Type: application/json' \\
--data-raw '{
 "audience": "https://api.sitecorecloud.io",
 "grant\_type": "client\_credentials",
 "client\_id": "<YOUR\_CLIENT\_ID>",
 "client\_secret": "<YOUR\_CLIENT\_SECRET>"
}'

::::::tab{title="URL-encoded"}

curl -X POST 'https://auth.sitecorecloud.io/oauth/token' \\
-H 'content-type: application/x-www-form-urlencoded' \\
--data-urlencode 'audience=https://api.sitecorecloud.io' \\
--data-urlencode 'grant\_type=client\_credentials' \\
--data-urlencode 'client\_id=<YOUR\_CLIENT\_ID>' \\
--data-urlencode 'client\_secret=<YOUR\_CLIENT\_SECRET>'

:::::::以下はその回答の例です:

{
 "access\_token": "eyJhbG...",
 "scope": "...",
 "expires\_in": 86400,
 "token\_type": "Bearer"
}

回答では:

-   access\_token はJSONのウェブトークンです。JWTを使って管理者REST APIやトークンREST APIへの [リクエストを承認](https://doc.sitecore.com/sai/ja/developers/sitecoreai/experience-edge/experience-edge-apis/authorization-and-api-access.html#authorize-requests-to-the-admin-rest-api-and-the-token-rest-api) したり、 [プログラム的に](https://doc.sitecore.com/sai/ja/developers/sitecoreai/experience-edge/experience-edge-apis/authorization-and-api-access.html#programmatically-create-delivery-graphql-api-tokens) デリバリー GraphQL APIトークンを作成したりできます。
-   scope JWTがアクセスを提供するリソースを定義します。リソースは作成した資格の種類によって異なります。
-   expires\_in JWTの妥当性を秒単位で定義します。JWTは通常24時間で有効期限が切れますのでご注意ください。その時間が経つとトークンは無効となり、新しいトークンを申請する必要があります。
-   token\_type はBearerのように作成されるトークンの種類を定義します。

## セキュリティ上の考慮事項

Sitecore発行のJWTはRS256で署名されています。JWTを使用する前に、JWTライブラリを使ってSitecoreのJSON Web Key Set(JWKS)URIと比較して検証してください:

[https://auth.sitecorecloud.io/.well-known/jwks.json](https://auth.sitecorecloud.io/.well-known/jwks.json)

JWKS URIは署名の検証に使われる公開鍵を提供します。JWTライブラリを設定して、期待される発行者(https://auth.sitecorecloud.io/)とオーディエンス(https://api.sitecorecloud.io)を確認し、期限確認が無効化されていないことを確認してください。どのカードが自動的に検証されているか、図書館のドキュメントを確認してください。自分の認証情報申請から直接取得していないJWTは絶対に使わないでください。