Tencent OneID 身份安全 更新用户信息

更新已登录用户的个人信息。调用此接口时,需携带登录成功时得到的具备 openid scope 的 Access Token。如果更新手机号或邮箱,则需先调用 发送 OTP 验证码 接口向用户发送验证码。

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

一、支持的应用类型

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

二、请求方法

PATCH

三、请求路径

/userinfo

四、请求 Content-Type

application/json

五、请求示例

PATCH /userinfo HTTP/1.1Content-Type: application/jsonAuthorization: Bearer ACCESS_TOKEN_WITH_OPENID_SCOPEHost: sample.portal.tencentciam.com{ "nickname" : "MOCK_NICKNAME"}

六、请求头

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

七、请求体 JSON 参数

JSON 路径 数据类型 描述
phone_number String 用户的手机号,限国内三大运营商11位手机号。传递此参数时,须同时传递 phone_number_otp_token 和 phone_number_otp 两个参数。
phone_number_otp_token String 发送短信验证码成功后服务端返回的 otp_token。
phone_number_otp String 用户手机收到的 OTP 验证码。
email String 用户的邮箱地址。传递此参数时,须同时传递 email_otp_token 和 email_otp 两个参数。
email_otp_token String 发送邮箱验证码成功后服务端返回的 otp_token。
email_otp String 用户邮箱收到的 OTP 验证码。
name String 用户姓名。
nickname String 用户昵称。
zoneinfo String 用户时区,如 Asia/Shanghai 或 Europe/Paris。
locale String 用户 locale 信息,如 zh-CN 或 en-US。

注意:其他参数的取值为用户属性标识。属性标识可以在 属性自定义页面 的属性详情界面查看。

八、正常响应示例

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"}

九、异常响应示例

·入参包含未知属性。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "invalid_request","error_description" : "Unknown attribute(s) found."}

·入参包含不支持修改的属性。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "invalid_request","error_description" : "Unsupported user attribute(s) found."}

·电话号码格式不合法。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "malformed_phone_number"}

·电话号码已存在。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "duplicate_phone_number"}

·phone_number_otp_token 错误或已过期,或注册时使用的参数与发送验证码时不一致(例如:手机号不同)。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "bad_phone_number_otp_token"}

·phone_number_otp 错误或已过期。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "bad_phone_number_otp"}

·邮箱格式不合法。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "malformed_email"}

·邮箱已存在。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "duplicate_email"}

·email_otp_token 错误或已过期,或注册时使用的参数与发送验证码时不一致(例如:邮箱不同)。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "bad_email_otp_token"}

·email_otp 错误或已过期。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "bad_email_otp"}

·入参取值不合法(例如:不符合用户属性正则表达式)。

HTTP/1.1 400 Bad RequestContent-Type: application/json;charset=UTF-8{"error" : "illegal_parameter_value"}

·bearer_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"

·bearer_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"

·bearer_token 无效。

HTTP/1.1 403 ForbiddenWWW-Authenticate: Bearer error="insufficient_scope", error_description="The request requires higher privil

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