生成一个JWT认证令牌。
接口说明
该 API 基于 IDaaS 签发的 Access Token 进行身份认证和鉴权。
请确保传入的 Access Token 具备访问 IDaaS 内置 PAM 应用(Privileged Access Management)的“获取认证令牌”的功能授权。
对应的 scope 为urn:cloud:idaas:pam|authentication_token:obtain。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
POST /v2/{instanceId}/authenticationTokens/_/actions/generateJwt HTTP/1.1
路径参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| instanceId |
string |
是 |
实例 ID。 |
idaas_ue2jvisn35ea5lmthk267xxxxx |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Authorization |
string |
是 |
认证信息。 格式为:Bearer ${access_token}。 说明
请输入 IDaaS 签发的 Access Token。 |
Bearer xxxxxx |
| body |
object |
否 |
请求 Body。 |
|
| credentialProviderIdentifier |
string |
是 |
凭据提供商标识。 |
test_example_identifier |
| issuer |
string |
否 |
对应 JWT 的 iss 字段。 |
https://test.issuer.com |
| subject |
string |
是 |
对应 JWT 的 sub 字段。 |
test_jwt_subject |
| audiences |
array |
是 |
对应 JWT 的 aud 字段。 |
|
|
string |
否 |
JWT 受众。 |
test_jwt_audience |
|
| customClaims |
object |
否 |
自定义 Claims。 重要 键值对形式,其中键必须为字符串类型。 |
|
|
any |
否 |
自定义 Claim 键值对。 |
- |
|
| expiration |
integer |
否 |
JWT 的有效时长,单位秒。 |
900 |
| includeDerivedShortToken |
boolean |
否 |
生成 JWT 是否需要包含“派生短令牌”。 |
true |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
JWT 认证令牌详情。 |
||
| instanceId |
string |
实例 ID。 |
idaas_ue2jvisn35ea5lmthk267xxxxx |
| authenticationTokenId |
string |
认证令牌 ID。 |
atntkn_01kqflm0sxxx8nmdc1cb5dskxxxxx |
| credentialProviderId |
string |
凭据提供商 ID。 |
atp_01kr2cmj5gxxx4fvmls2e93dxxxxx |
| createTime |
integer |
认证令牌的创建时间,Unix 时间戳,单位毫秒。 |
1649830225000 |
| updateTime |
integer |
认证令牌的更新时间,Unix 时间戳,单位毫秒。 |
1649830225000 |
| authenticationTokenType |
string |
认证令牌类型。 说明
取值固定为 |
jwt |
| revoked |
boolean |
认证令牌是否被吊销。 |
false |
| creatorType |
string |
认证令牌创建者类型。取值可选范围:
|
application |
| creatorId |
string |
认证令牌创建者 ID。 |
app_ngtkgrrxxxxktg5eao6z4xxxxx |
| consumerType |
string |
认证令牌使用者类型。取值可选范围:
|
custom |
| consumerId |
string |
认证令牌使用者 ID。 |
test_jwt_subject |
| expirationTime |
integer |
认证令牌过期时间,Unix 时间戳,单位毫秒。 |
1772693568000 |
| jwtContent |
object |
JWT 类型认证令牌内容。 |
|
| jwtValue |
string |
JWT 内容。 |
eyJhbGciOixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| derivedShortToken |
string |
JWT 的派生短令牌。 |
sk-Nx2vzxxxxxxxxxxxxxxxxx |
示例
正常返回示例
JSON格式
{
"instanceId": "idaas_ue2jvisn35ea5lmthk267xxxxx",
"authenticationTokenId": "atntkn_01kqflm0sxxx8nmdc1cb5dskxxxxx",
"credentialProviderId": "atp_01kr2cmj5gxxx4fvmls2e93dxxxxx",
"createTime": 1649830225000,
"updateTime": 1649830225000,
"authenticationTokenType": "jwt",
"revoked": false,
"creatorType": "application",
"creatorId": "app_ngtkgrrxxxxktg5eao6z4xxxxx",
"consumerType": "custom",
"consumerId": "test_jwt_subject",
"expirationTime": 1772693568000,
"jwtContent": {
"jwtValue": "eyJhbGciOixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"derivedShortToken": "sk-Nx2vzxxxxxxxxxxxxxxxxx"
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。