Tencent OneID 身份安全 获取用户信息

获取已登录用户的用户信息。调用此接口时,需携带登录成功时得到的具备 openid scope 的 Access Token。

相关产品
Tencent OneID 身份安全 产品页,含版本规格、价格与购买入口。

一、支持的应用类型

Web 应用、单页应用、移动 App、M2M 应用、小程序应用。

二、请求方法

GET

三、请求路径

/userinfo

四、请求示例

GET /userinfo HTTP/1.1Authorization: Bearer ACCESS_TOKEN_WITH_OPENID_SCOPEHost: sample.portal.tencentciam.com

五、请求头

名称 描述
Authorization OAuth 2.0 Bearer Token,格式为 Bearer <Token>,其中 Bearer 为固定字符串,<Token> 为用户登录成功时得到的具备 openid scope 的 Access Token,Bearer 和 <Token> 之间用一个空格隔开。

六、正常响应示例

HTTP/1.1 200 OKContent-Type: application/json{ "sub" : "MOCK_USER_ID", "email" : "MOCK_USERNAME@example.com", "name" : "MOCK_NAME", "nickname" : "MOCK_NICKNAME", "zoneinfo" : "Asia/Shanghai", "locale" : "zh-CN"}

七、响应参数

参数 数据类型 描述
sub String 用户标识,在用户池内唯一。

八、异常响应示例

·未携带 Access Token。

HTTP/1.1 400 Bad RequestWWW-Authenticate: Bearer error="invalid_request", error_description="Bearer token not found in the request", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"

·Access Token 无效(例如 Token 格式有误、已过期或已注销)。

HTTP/1.1 401 UnauthorizedWWW-Authenticate: Bearer error="invalid_token", error_description="Error decoding JWT", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"

·Access Token 不具备 openid scope。

HTTP/1.1 403 ForbiddenWWW-Authenticate: Bearer error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token.", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"

·找不到 Access Token 对应的用户。

HTTP/1.1 404 Not FoundContent-Type: application/json;charset=UTF-8{"error" : "user_not_found"}

赞 (0)
上一篇 4天前
下一篇 4天前