Authorization Server - Create Or Update
创建新的授权服务器或更新现有授权服务器。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}?api-version=2024-05-01
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
authsid
|
path | True |
string minLength: 1maxLength: 80 pattern: ^[^*#&+:<>?]+$ |
授权服务器的标识符。 |
|
resource
|
path | True |
string minLength: 1maxLength: 90 |
资源组的名称。 名称不区分大小写。 |
|
service
|
path | True |
string minLength: 1maxLength: 50 pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$ |
API 管理服务的名称。 |
|
subscription
|
path | True |
string (uuid) |
目标订阅的 ID。 该值必须是 UUID。 |
|
api-version
|
query | True |
string minLength: 1 |
用于此作的 API 版本。 |
请求头
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| If-Match |
string |
实体的 ETag。 创建实体时不需要,但在更新实体时是必需的。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| properties.authorizationEndpoint | True |
string |
OAuth 授权终结点。 请参阅 http://tools.ietf.org/html/rfc6749#section-3.2。 |
| properties.clientId | True |
string |
向此授权服务器注册的客户端或应用 ID。 |
| properties.clientRegistrationEndpoint | True |
string |
对执行此授权服务器的客户端或应用注册的页面的可选引用。 包含所引用实体的绝对 URL。 |
| properties.displayName | True |
string minLength: 1maxLength: 50 |
用户友好的授权服务器名称。 |
| properties.grantTypes | True |
客户端用来请求访问令牌的授权形式。 |
|
| properties.authorizationMethods |
授权终结点支持的 HTTP 谓词。 GET 必须始终存在。 POST 是可选的。 |
||
| properties.bearerTokenSendingMethods |
指定将访问令牌传递给 API 的机制。 |
||
| properties.clientAuthenticationMethod |
此授权服务器的令牌终结点支持的身份验证方法。 可能的值为 Basic 和/或 Body。 指定正文时,客户端凭据和其他参数在 application/x-www-form-urlencoded 格式的请求正文中传递。 |
||
| properties.clientSecret |
string |
向此授权服务器注册的客户端或应用机密。 此属性不会在“GET”作上填充! 使用“/listSecrets”POST 请求获取值。 |
|
| properties.defaultScope |
string |
默认情况下将请求的访问令牌范围。 可以在 API 级别重写。 应以包含空格分隔值的字符串的形式提供。 |
|
| properties.description |
string |
授权服务器的说明。 可以包含 HTML 格式标记。 |
|
| properties.resourceOwnerPassword |
string |
当此授权服务器支持资源所有者密码授予类型时,可以选择指定。 默认资源所有者密码。 |
|
| properties.resourceOwnerUsername |
string |
当此授权服务器支持资源所有者密码授予类型时,可以选择指定。 默认资源所有者用户名。 |
|
| properties.supportState |
boolean |
如果为 true,授权服务器将包含授权请求到其响应的状态参数。 客户端可以使用状态参数提高协议安全性。 |
|
| properties.tokenBodyParameters |
此授权服务器的令牌终结点所需的附加参数,这些参数表示为具有名称和值字符串属性的 JSON 对象数组,即 {“name”: “name value”, “value”: “a value”}。 |
||
| properties.tokenEndpoint |
string |
OAuth 令牌终结点。 包含所引用实体的绝对 URI。 |
|
| properties.useInApiDocumentation |
boolean |
如果为 true,授权服务器将在开发人员门户中的 API 文档中使用。 如果未提供任何值,则默认为 False。 |
|
| properties.useInTestConsole |
boolean |
如果为 true,可以在开发人员门户测试控制台中使用授权服务器。 如果未提供任何值,则默认为 True。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
授权服务器已注册。 标头 ETag: string |
|
| 201 Created |
授权服务器已成功注册。 标头 ETag: string |
|
| Other Status Codes |
描述作失败的原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
ApiManagementCreateAuthorizationServer
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer?api-version=2024-05-01
{
"properties": {
"displayName": "test2",
"useInTestConsole": false,
"useInApiDocumentation": true,
"description": "test server",
"clientRegistrationEndpoint": "https://www.contoso.com/apps",
"authorizationEndpoint": "https://www.contoso.com/oauth2/auth",
"authorizationMethods": [
"GET"
],
"tokenEndpoint": "https://www.contoso.com/oauth2/token",
"supportState": true,
"defaultScope": "read write",
"grantTypes": [
"authorizationCode",
"implicit"
],
"bearerTokenSendingMethods": [
"authorizationHeader"
],
"clientId": "1",
"clientSecret": "2",
"resourceOwnerUsername": "un",
"resourceOwnerPassword": "pwd"
}
}
示例响应
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer",
"type": "Microsoft.ApiManagement/service/authorizationServers",
"name": "newauthServer",
"properties": {
"displayName": "test2",
"useInTestConsole": false,
"useInApiDocumentation": true,
"description": "test server",
"clientRegistrationEndpoint": "https://www.contoso.com/apps",
"authorizationEndpoint": "https://www.contoso.com/oauth2/auth",
"authorizationMethods": [
"GET"
],
"tokenEndpoint": "https://www.contoso.com/oauth2/token",
"supportState": true,
"defaultScope": "read write",
"grantTypes": [
"authorizationCode",
"implicit"
],
"bearerTokenSendingMethods": [
"authorizationHeader"
],
"clientId": "1",
"resourceOwnerUsername": "un",
"resourceOwnerPassword": "pwd"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationServers/newauthServer",
"type": "Microsoft.ApiManagement/service/authorizationServers",
"name": "newauthServer",
"properties": {
"displayName": "test2",
"useInTestConsole": false,
"useInApiDocumentation": true,
"description": "test server",
"clientRegistrationEndpoint": "https://www.contoso.com/apps",
"authorizationEndpoint": "https://www.contoso.com/oauth2/auth",
"authorizationMethods": [
"GET"
],
"tokenEndpoint": "https://www.contoso.com/oauth2/token",
"supportState": true,
"defaultScope": "read write",
"grantTypes": [
"authorizationCode",
"implicit"
],
"bearerTokenSendingMethods": [
"authorizationHeader"
],
"clientId": "1",
"resourceOwnerUsername": "un",
"resourceOwnerPassword": "pwd"
}
}
定义
| 名称 | 说明 |
|---|---|
|
Authorization |
授权终结点支持的 HTTP 谓词。 GET 必须始终存在。 POST 是可选的。 |
|
Authorization |
外部 OAuth 授权服务器设置。 |
|
Bearer |
指定将访问令牌传递给 API 的机制。 |
|
Client |
此授权服务器的令牌终结点支持的身份验证方法。 可能的值为 Basic 和/或 Body。 指定正文时,客户端凭据和其他参数在 application/x-www-form-urlencoded 格式的请求正文中传递。 |
|
Error |
资源管理错误附加信息。 |
|
Error |
错误详细信息。 |
|
Error |
错误响应 |
|
Grant |
客户端用来请求访问令牌的授权形式。 |
|
Token |
OAuth 获取令牌请求正文参数(www-url-form-encoded)。 |
AuthorizationMethod
授权终结点支持的 HTTP 谓词。 GET 必须始终存在。 POST 是可选的。
| 值 | 说明 |
|---|---|
| HEAD | |
| OPTIONS | |
| TRACE | |
| GET | |
| POST | |
| PUT | |
| PATCH | |
| DELETE |
AuthorizationServerContract
外部 OAuth 授权服务器设置。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| name |
string |
资源的名称 |
| properties.authorizationEndpoint |
string |
OAuth 授权终结点。 请参阅 http://tools.ietf.org/html/rfc6749#section-3.2。 |
| properties.authorizationMethods |
授权终结点支持的 HTTP 谓词。 GET 必须始终存在。 POST 是可选的。 |
|
| properties.bearerTokenSendingMethods |
指定将访问令牌传递给 API 的机制。 |
|
| properties.clientAuthenticationMethod |
此授权服务器的令牌终结点支持的身份验证方法。 可能的值为 Basic 和/或 Body。 指定正文时,客户端凭据和其他参数在 application/x-www-form-urlencoded 格式的请求正文中传递。 |
|
| properties.clientId |
string |
向此授权服务器注册的客户端或应用 ID。 |
| properties.clientRegistrationEndpoint |
string |
对执行此授权服务器的客户端或应用注册的页面的可选引用。 包含所引用实体的绝对 URL。 |
| properties.clientSecret |
string |
向此授权服务器注册的客户端或应用机密。 此属性不会在“GET”作上填充! 使用“/listSecrets”POST 请求获取值。 |
| properties.defaultScope |
string |
默认情况下将请求的访问令牌范围。 可以在 API 级别重写。 应以包含空格分隔值的字符串的形式提供。 |
| properties.description |
string |
授权服务器的说明。 可以包含 HTML 格式标记。 |
| properties.displayName |
string minLength: 1maxLength: 50 |
用户友好的授权服务器名称。 |
| properties.grantTypes |
客户端用来请求访问令牌的授权形式。 |
|
| properties.resourceOwnerPassword |
string |
当此授权服务器支持资源所有者密码授予类型时,可以选择指定。 默认资源所有者密码。 |
| properties.resourceOwnerUsername |
string |
当此授权服务器支持资源所有者密码授予类型时,可以选择指定。 默认资源所有者用户名。 |
| properties.supportState |
boolean |
如果为 true,授权服务器将包含授权请求到其响应的状态参数。 客户端可以使用状态参数提高协议安全性。 |
| properties.tokenBodyParameters |
此授权服务器的令牌终结点所需的附加参数,这些参数表示为具有名称和值字符串属性的 JSON 对象数组,即 {“name”: “name value”, “value”: “a value”}。 |
|
| properties.tokenEndpoint |
string |
OAuth 令牌终结点。 包含所引用实体的绝对 URI。 |
| properties.useInApiDocumentation |
boolean |
如果为 true,授权服务器将在开发人员门户中的 API 文档中使用。 如果未提供任何值,则默认为 False。 |
| properties.useInTestConsole |
boolean |
如果为 true,可以在开发人员门户测试控制台中使用授权服务器。 如果未提供任何值,则默认为 True。 |
| type |
string |
资源的类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts” |
BearerTokenSendingMethod
指定将访问令牌传递给 API 的机制。
| 值 | 说明 |
|---|---|
| authorizationHeader | |
| query |
ClientAuthenticationMethod
此授权服务器的令牌终结点支持的身份验证方法。 可能的值为 Basic 和/或 Body。 指定正文时,客户端凭据和其他参数在 application/x-www-form-urlencoded 格式的请求正文中传递。
| 值 | 说明 |
|---|---|
| Basic |
基本客户端身份验证方法。 |
| Body |
基于正文的身份验证方法。 |
ErrorAdditionalInfo
资源管理错误附加信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| info |
object |
其他信息。 |
| type |
string |
其他信息类型。 |
ErrorDetail
错误详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误附加信息。 |
|
| code |
string |
错误代码。 |
| details |
错误详细信息。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误目标。 |
ErrorResponse
错误响应
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误对象。 |
GrantType
客户端用来请求访问令牌的授权形式。
| 值 | 说明 |
|---|---|
| authorizationCode |
授权代码授予流,如 https://tools.ietf.org/html/rfc6749#section-4.1所述。 |
| implicit |
如 https://tools.ietf.org/html/rfc6749#section-4.2所述,隐式代码授予流。 |
| resourceOwnerPassword |
资源所有者密码授予流,如 https://tools.ietf.org/html/rfc6749#section-4.3所述。 |
| clientCredentials |
如 https://tools.ietf.org/html/rfc6749#section-4.4所述,客户端凭据授予流。 |
TokenBodyParameterContract
OAuth 获取令牌请求正文参数(www-url-form-encoded)。
| 名称 | 类型 | 说明 |
|---|---|---|
| name |
string |
body 参数名称。 |
| value |
string |
body 参数值。 |