你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
User - Get Shared Access Token
获取用户的共享访问授权令牌。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token?api-version=2022-08-01
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
resource
|
path | True |
string |
资源组的名称。 此名称不区分大小写。 |
service
|
path | True |
string |
API 管理服务的名称。 Regex pattern: |
subscription
|
path | True |
string |
目标订阅的 ID。 |
user
|
path | True |
string |
用户标识符。 在当前API 管理服务实例中必须是唯一的。 |
api-version
|
query | True |
string |
要用于此操作的 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
properties.expiry | True |
string |
令牌的到期时间。 最长令牌过期时间设置为 30 天。 日期符合以下格式: |
properties.keyType | True |
用于为用户生成令牌的密钥。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
响应正文包含用户的授权令牌。 |
|
Other Status Codes |
描述操作失败原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 | 说明 |
---|---|
user_impersonation | 模拟用户帐户 |
示例
ApiManagementUserToken
Sample Request
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/userId1718/token?api-version=2022-08-01
{
"properties": {
"keyType": "primary",
"expiry": "2019-04-21T00:44:24.2845269Z"
}
}
Sample Response
{
"value": "userId1718&201904210044&9A1GR1f5WIhFvFmzQG+xxxxxxxxxxx/kBeu87DWad3tkasUXuvPL+MgzlwUHyg=="
}
定义
名称 | 说明 |
---|---|
Error |
错误字段协定。 |
Error |
错误响应。 |
Key |
用于为用户生成令牌的密钥。 |
User |
获取用户令牌参数。 |
User |
获取用户令牌响应详细信息。 |
ErrorFieldContract
错误字段协定。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
属性级错误代码。 |
message |
string |
属性级错误的可读表示形式。 |
target |
string |
属性名称。 |
ErrorResponse
错误响应。
名称 | 类型 | 说明 |
---|---|---|
error.code |
string |
服务定义的错误代码。 此代码用作响应中指定的 HTTP 错误代码的子状态。 |
error.details |
在发生验证错误的情况下,在请求中发送的无效字段列表。 |
|
error.message |
string |
错误的用户可读表示形式。 |
KeyType
用于为用户生成令牌的密钥。
名称 | 类型 | 说明 |
---|---|---|
primary |
string |
|
secondary |
string |
UserTokenParameters
获取用户令牌参数。
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
properties.expiry |
string |
令牌的到期时间。 最长令牌过期时间设置为 30 天。 日期符合以下格式: |
|
properties.keyType | primary |
用于为用户生成令牌的密钥。 |
UserTokenResult
获取用户令牌响应详细信息。
名称 | 类型 | 说明 |
---|---|---|
value |
string |
用户的共享访问授权令牌。 |