ID トークンへのクレームの追加

はじめに


本記事では、クレームを ID トークンに追加する方法について説明します。

クレームの追加


クレームの追加は /auth/authorization/issue API により行います。本記事では次のクレームを追加します。
項目
"name"
"Test User"
"email"
"testuser01@example.com"
"email_verified"
true


クレームの追加には claims パラメーターを利用します。リクエストは以下のようなかたちになります。(一部折り返しています)

curl -s -X POST https://api.authlete.com/api/auth/authorization/issue \
-u '<API Key>:<API Secret>' \
-H 'Content-Type: application/json' \
-d '{ "ticket": "<Ticket>", "subject": "testuser01",
 "claims": "{\"name\": \"Test User\",
  \"email\": \"testuser01@example.com\",
  \"email_verified\": true}"
 }'

これにより Authlete は、追加されたクレームを含む ID トークンを発行します。以下はその ID トークンのペイロードの内容です。

{
  "name": "Test User",
  "email": "testuser01@example.com",
  "email_verified": true,
  "iss": "https://as.example.com",
  "sub": "testuser01",
  "aud": [
    "12898884596863"
  ],
  "exp": 1559137301,
  "iat": 1559050901,
  "nonce": "n-0S6_WzA2Mj"
}
How did we do with this article?