Get JWKS (Public Keys)
ดึง JSON Web Key Set (JWKS) ที่ประกอบด้วย public keys สำหรับ verify JWT tokens (access token และ id_token) ที่ออกโดย HMS Auth Server
Endpoint นี้ส่ง response ตรงตามมาตรฐาน JWKS โดยไม่ wrap ใน {code, payload} — สามารถใช้กับ JWKS client libraries ได้โดยตรง
Endpoint
GET /oauth2/v1/.well-known/jwks.jsonRequest Parameters
ไม่มี parameters
Response Format
Success Response
{
"keys": [
{
"kid": "key-id-uuid",
"kty": "RSA",
"n": "modulus_base64url",
"e": "AQAB",
"use": "sig",
"alg": "RS256"
}
]
}Response Fields
| Field | Type | Description |
|---|---|---|
keys | array | รายการ public keys |
keys[].kid | string | Key ID — ใช้จับคู่กับ kid ใน JWT header |
keys[].kty | string | Key type — จะเป็น RSA เสมอ |
keys[].n | string | RSA modulus (Base64URL encoded) |
keys[].e | string | RSA exponent (Base64URL encoded) — ปกติจะเป็น AQAB |
keys[].use | string | การใช้งาน — sig (signature) |
keys[].alg | string | Algorithm — RS256 |
Code Examples
cURL
curl -X GET https://auth.humansoft.co.th/oauth2/v1/.well-known/jwks.jsonNotes
- ควรใช้ cache สำหรับ JWKS เพื่อลดการเรียก API ซ้ำ แนะนำให้ cache อย่างน้อย 24 ชั่วโมง
- ใช้
kid(Key ID) จาก JWT header เพื่อเลือก key ที่ถูกต้องจาก JWKS - Tokens ทั้งหมดใช้ algorithm
RS256(RSA Signature with SHA-256)
Related APIs
- Token Endpoint - ขอ token
- Token Introspection - ตรวจสอบ token ผ่าน API (ทางเลือกแทนการ verify ด้วย JWKS)
- User Info - ดึงข้อมูล user จาก access token
Last updated on