Skip to content

检查Token有效性

检查当前用户的token是否有效,若token有效,则返回true;若无效或者token已过期,则返回false。

请求说明

http
POST https://{your_domain}/api/v1/oauth2/introspect

请求头

参数名中文名称必填示例值描述
Authorization认证信息必须Basic UnFCMkOWk9xWA==使用client_id和client_secret进行basic64认证,
格式为: base64(client_id:client_secret)
Content-Type数据类型必须application/x-www-form-urlencoded使用表单方式提交参数

请求示例

http
POST https://{your_domain}/api/v1/oauth2/introspect

Authorization: Basic UnFCMkhKdGt6bFU...aT0NObkk4NlNOWk9xWA==

Content-Type: application/x-www-form-urlencoded

token=MmVkMTIyNGUzODBkYjY3UV4nmxKh4z....&token_type_hint=access_token

请求参数

参数名中文名称必填示例值描述
token令牌
token_type_hint可选默认为 access_token

返回示例

成功示例

当token有效时,正确返回示例

HTTP/1.1 200 OK

json
{
	"active": true,
    "token_type""bearer",
 	"scope": "openid profile",
	"client_id": "J8NFmU4tJVgDxKaJFmXTWvaHO",
	"username": "zhangsan",
	"exp": 1437275311
}

当token无效或者过期时,正确返回示例

HTTP/1.1 200 OK

json
{
	"active": false,
}

错误示例

HTTP 401 Unauthorized

json
{ 	
    "error": "invalid_client",    
    "error_description": "Bad client credentials"
}

返回参数

如果成功返回,即可在返回信息中获取到Access Token。

参数名中文名称必填描述
active令牌状态必须true标识token有效 false表示token无效或过期
token_type令牌类型可选
scope授权范围可选
client_id应用客户端ID可选
username用户名可选
exp失效时间可选Unix时间戳

竹云IDaaS开放平台