更新消费者凭证
更新时间:2026-11-30
该接口用于更新指定的消费者凭证,并刷新相关实例的鉴权配置。认证类型不可修改。
注意事项:
- 按
authorizationInfoId更新;凭证不存在或不属于当前账号时返回 404。 authorizationType必须与该凭证现有类型一致,不支持修改类型。- API_KEY 按
apiKeyConfig重新生成或替换 API Key;AK/SK 仅重新生成 SK,AK 保持不变;JWT 整体替换jwtConfig,identifyClaimValue为空时沿用原值。 - 返回的 API Key、SK 明文仅在本次响应中返回,请及时保存。
请求结构
Plain Text
1POST /?action=UpdateConsumerAuthorizationInfo HTTP/1.1
2Host: apigw-control.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "authorizationInfoId": authorizationInfoId,
7 "authorizationType": authorizationType,
8 "apiKeyConfig": {
9 "createType": createType,
10 "apiKey": apiKey
11 },
12 "jwtConfig": {
13 "mode": mode,
14 "localJwks": {
15 "secretType": secretType,
16 "jwks": jwks
17 },
18 "remoteJwks": {
19 "uri": uri,
20 "port": port,
21 "refreshIntervalMs": refreshIntervalMs,
22 "fetchTimeoutMs": fetchTimeoutMs
23 },
24 "jwtTokenConfig": {
25 "position": position,
26 "key": key,
27 "prefix": prefix,
28 "pass": pass
29 },
30 "jwtPayloadConfig": {
31 "identifyClaim": identifyClaim,
32 "identifyClaimValue": identifyClaimValue
33 },
34 "claimsToHeaders": [
35 {
36 "claim": claim,
37 "header": header,
38 "overwrite": overwrite
39 }
40 ]
41 }
42}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| authorizationInfoId | String | 是 | RequestBody参数 | 鉴权信息 ID |
| authorizationType | String | 是 | RequestBody参数 | 认证类型:API_KEY / AK_SK / JWT,必须与该凭证现有类型一致 |
| apiKeyConfig | ApiKeyConfigReq | 否 | RequestBody参数 | API_KEY 专属配置,缺省等同 createType=System;其他类型必须为空 |
| jwtConfig | JwtConfigReq | 否 | RequestBody参数 | JWT 专属配置,JWT 时必填;其他类型必须为空 |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| authorizationInfoId | String | 鉴权信息 ID |
| authorizationType | String | 认证类型:API_KEY / AK_SK / JWT |
| apiKey | String | API Key 明文,仅 API_KEY 类型有值 |
| ak | String | Access Key 明文,仅 AK_SK 类型有值 |
| sk | String | Secret Key 明文,仅 AK_SK 类型有值,仅在本次响应中返回 |
| identifyClaim | String | JWT 身份识别 claim 名,仅 JWT 类型有值 |
| identifyClaimValue | String | JWT 身份识别 claim 值,仅 JWT 类型有值 |
错误码
| 错误码 | 错误描述 | HTTP 状态码 | 中文解释 |
|---|---|---|---|
| MethodArgumentNotValidException | MethodArgumentNotValidException: authorizationInfoId must not be blank | 400 | 必填参数缺失或格式不合法,authorizationInfoId 不能为空 |
| HttpMessageNotReadable | Http Message Not Readable: JSON parse error | 400 | 请求体不是合法 JSON,无法解析,请检查 JSON 语法和字段类型 |
| InvalidParameter.AuthorizationType | Authorization type is invalid. | 400 | 认证类型取值非法 |
| InvalidParameter.ApiKeyConfig | apiKeyConfig is only allowed for API_KEY authorization type. | 400 | 非 API_KEY 类型不允许传 apiKeyConfig |
| InvalidParameter.JwtConfig | jwtConfig is only allowed for JWT authorization type. | 400 | 非 JWT 类型不允许传 jwtConfig,或 JWT 配置不合法 |
| MissingParameter.JwtConfig | jwtConfig is required for JWT authorization type. | 400 | JWT 类型必须传 jwtConfig |
| AuthorizationInfo.NotFound | Authorization information does not exist. | 404 | 凭证不存在、不属于当前账号或已删除 |
| Consumer.ApiKeyDuplicate | API Key already exists in this account. | 409 | API Key 已存在于当前账号下,请更换 |
| Authorization.Conflict | Authorization type cannot be changed. | 409 | 认证类型不可修改,请保持与该凭证现有类型一致 |
| Consumer.JwtIdentityDuplicate | JWT identity already exists in this account. | 409 | JWT 身份标识(identifyClaim、identifyClaimValue)在当前账号内已存在 |
| HttpMediaTypeException | HttpMediaTypeException: Content-Type 'text/plain' is not supported | 415 | 请求的 Content-Type 不受支持,请使用 application/json |
| DataPlane.SyncFailed | Configuration was saved, but consumer authentication synchronization failed. | 500 | 配置已保存,但消费者认证配置同步失败,请稍后重新保存该凭证重试或联系技术支持 |
请求示例
Plain Text
1POST /?action=UpdateConsumerAuthorizationInfo HTTP/1.1
2Host: apigw-control.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4
5{
6 "authorizationInfoId": "authorization_info-m3n4o5p6",
7 "authorizationType": "API_KEY",
8 "apiKeyConfig": {
9 "createType": "System"
10 }
11}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6
7{
8 "authorizationInfoId": "authorization_info-m3n4o5p6",
9 "authorizationType": "API_KEY",
10 "apiKey": "ak-3f8e2d1c9b7a4e6f",
11 "ak": "",
12 "sk": ""
13}
评价此篇文章
