Token Introspection
ตรวจสอบว่า token ยังใช้งานได้หรือไม่ ตามมาตรฐาน RFC 7662
Endpoint นี้ส่ง response ตรงตามมาตรฐาน RFC 7662 โดยไม่ wrap ใน {code, payload}
Endpoint
POST /oauth2/v1/introspect
Content-Type: application/json
Authorization: Basic base64(client_id:client_secret)Request Headers
| Header | Required | Description |
|---|---|---|
Authorization | ✅ | Basic base64(client_id:client_secret) |
Content-Type | ✅ | application/json |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | ✅ | Token ที่ต้องการตรวจสอบ |
token_type_hint | string | ⬜ | ชนิดของ token เช่น access_token |
Response Format
Active Token
{
"active": true,
"sub": "user-credential-id",
"user_id": "456",
"scope": "openid profile email",
"aud": "my-app",
"iss": "https://auth.humansoft.co.th",
"iat": 1735090800,
"exp": 1735094400
}Inactive Token หรือ Credentials ไม่ถูกต้อง
{
"active": false
}ถ้า client credentials ไม่ถูกต้อง ระบบจะส่ง {"active": false} เช่นเดียวกับ token ที่หมดอายุ เพื่อไม่ให้เปิดเผยข้อมูล
Response Fields
| Field | Type | Description |
|---|---|---|
active | boolean | true ถ้า token ยังใช้งานได้ |
sub | string | Subject identifier (user credential ID) |
user_id | string | User ID |
scope | string | Scopes ที่ token มีสิทธิ์ |
aud | string | Audience (client_id ที่ token ถูกออกให้) |
iss | string | Issuer URL |
iat | number | Issued at (Unix timestamp) |
exp | number | Expiration time (Unix timestamp) |
Code Examples
cURL
curl -X POST https://auth.humansoft.co.th/oauth2/v1/introspect \
-H "Content-Type: application/json" \
-H "Authorization: Basic bXktYXBwOkNMSUVOVF9TRUNSRVQ=" \
-d '{"token": "ACCESS_TOKEN_HERE"}'Related APIs
- Token Endpoint - ขอ token ใหม่
- Token Revocation - ยกเลิก token
- Get JWKS - ดึง public keys สำหรับ verify JWT tokens ด้วยตัวเอง
Last updated on