验证票据

最后更新时间: 1/22/2024, 6:45:10 PM

应用验证票据,并获取用户属性信息。

# 请求说明

GET https://{your_domain}/api/v1/cas/p3/serviceValidate

# 请求参数

参数名 中文名称 必须 示例值 描述
service 回调地址 应用接受票据的地址,必须与应用CAS配置中的应用回调URL一致。
ticket 验证票据 sSoIc1T8Jh0wPCQmNzvA 票据,认证登录获取的Service Ticket
format 格式类型 响应用户信息的格式,可选择XML和JSON。 缺省值:XML

# 请求示例

GET https://{your_domain}/api/v1/cas/p3/serviceValidate?ticket=SoIc1T8Jh0wPCQmNzvA&service=http://casdemo.bccastle.com/demo/callback

# 返回参数

如果成功返回,除了固定参数user为用户名,可通过应用管理-认证配置-映射配置,添加自定义参数映射。映射参数在attributes下返回以下参数调用,都以添加手机号mobile参数为例进行描述。

参数名 中文名称 必须 示例值 描述
serviceResponse 一层:响应对象 Object
authenticationSuccess 二层:认证成功 Object
attributes 三层:参数 Object
isFromNewLogin 四层 true 固定为true
authenticationDate 四层:认证时间 2022-03-08T01:34:12.460Z
longTermAuthenticationRequestTokenUsed 四层 false 固定为false
mobile 四层 +86-17322881122 通过认证映射配置动态添加的参数
user 三层:用户名

# 返回示例

以json格式返回正确示例

HTTP Status: 200 OK
format = JSON
{
    "serviceResponse": {
        "authenticationSuccess": {
            "attributes": {
                "isFromNewLogin": true,
                "authenticationDate": "2022-03-08T01:34:12.460Z",
                "longTermAuthenticationRequestTokenUsed": **false,**
                "mobile": "+86-17322881122"
            },
            "user": "admin"
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

以XML格式返回正确示例

HTTP Status: 200 OK
format = XML
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
    <cas:authenticationSuccess>
        <cas:user>admin</cas:user>
        <cas:attributes>
            <cas:authenticationDate>2022-03-08T01:34:12.460Z</cas:authenticationDate>
            <cas:longTermAuthenticationRequestTokenUsed>false</cas:longTermAuthenticationRequestTokenUsed>
            <cas:isFromNewLogin>true</cas:isFromNewLogin>
            <cas:mobile>+86-17322881122</cas:mobile>
        </cas:attributes>
    </cas:authenticationSuccess>
</cas:serviceResponse>
1
2
3
4
5
6
7
8
9
10
11
12
13

以JSON格式返回错误示例

HTTP Status: 200 OK
format=JSON
{
    "serviceResponse": {
        "authenticationFailure": {
            "code": "INVALID_TICKET",
            "description": "the ticket provided was not valid, ticket is &#39;jiVKc&#39"
        }
    }
}
1
2
3
4
5
6
7
8
9
10

以XML格式返回错误示例

HTTP Status: 200 OK
format=XML
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
    <cas:authenticationFailure code="INVALID_TICKET">
    	the ticket provided was not valid, ticket is &#39;jiVKc&#39;  
    </cas:authenticationFailure>
</cas:serviceResponse>
1
2
3
4
5
6
7