共用方式為


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 參數

名稱 位於 必要 類型 Description
authsid
path True

string

minLength: 1
maxLength: 80
pattern: ^[^*#&+:<>?]+$

授權伺服器的識別碼。

resourceGroupName
path True

string

minLength: 1
maxLength: 90

資源群組的名稱。 名稱不區分大小寫。

serviceName
path True

string

minLength: 1
maxLength: 50
pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

API 管理服務的名稱。

subscriptionId
path True

string (uuid)

目標訂用帳戶的標識碼。 此值必須是 UUID。

api-version
query True

string

minLength: 1

要用於這項作業的 API 版本。

要求標頭

名稱 必要 類型 Description
If-Match

string

實體的 ETag。 建立實體時不需要,但在更新實體時則為必要專案。

要求本文

名稱 必要 類型 Description
properties.authorizationEndpoint True

string

OAuth 授權端點。 請參閱 http://tools.ietf.org/html/rfc6749#section-3.2

properties.clientId True

string

向這個授權伺服器註冊的用戶端或應用程式標識碼。

properties.clientRegistrationEndpoint True

string

執行此授權伺服器的用戶端或應用程式註冊頁面的選擇性參考。 包含所參考實體的絕對 URL。

properties.displayName True

string

minLength: 1
maxLength: 50

使用者易記的授權伺服器名稱。

properties.grantTypes True

GrantType[]

用戶端用來要求存取令牌的授權授與形式。

properties.authorizationMethods

AuthorizationMethod[]

授權端點支援的 HTTP 動詞。 GET 必須一律存在。 POST 是選擇性的。

properties.bearerTokenSendingMethods

BearerTokenSendingMethod[]

指定將存取令牌傳遞至 API 的機制。

properties.clientAuthenticationMethod

ClientAuthenticationMethod[]

此授權伺服器的令牌端點所支持的驗證方法。 可能的值為 Basic 和/或 Body。 指定 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

TokenBodyParameterContract[]

此授權伺服器的令牌端點所需的其他參數,以名稱與值字串屬性表示為 JSON 對象的陣列,亦即 {“name” : “name value”, “value”: “a value”}。

properties.tokenEndpoint

string

OAuth 令牌端點。 包含所參考實體的絕對 URI。

properties.useInApiDocumentation

boolean

如果為 true,授權伺服器將會用於開發人員入口網站中的 API 檔。 如果未提供任何值,則預設為 False。

properties.useInTestConsole

boolean

如果為 true,授權伺服器可以在開發人員入口網站測試控制台中使用。 如果未提供任何值,則預設為 True。

回應

名稱 類型 Description
200 OK

AuthorizationServerContract

授權伺服器已註冊。

標題

ETag: string

201 Created

AuthorizationServerContract

已成功註冊授權伺服器。

標題

ETag: string

Other Status Codes

ErrorResponse

描述作業失敗原因的錯誤回應。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

類型: oauth2
Flow: implicit
授權 URL: https://login.microsoftonline.com/common/oauth2/authorize

範圍

名稱 Description
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"
  }
}

定義

名稱 Description
AuthorizationMethod

授權端點支援的 HTTP 動詞。 GET 必須一律存在。 POST 是選擇性的。

AuthorizationServerContract

外部 OAuth 授權伺服器設定。

BearerTokenSendingMethod

指定將存取令牌傳遞至 API 的機制。

ClientAuthenticationMethod

此授權伺服器的令牌端點所支持的驗證方法。 可能的值為 Basic 和/或 Body。 指定 Body 時,客戶端認證和其他參數會在 application/x-www-form-urlencoded 格式的要求本文內傳遞。

ErrorAdditionalInfo

資源管理錯誤其他資訊。

ErrorDetail

錯誤詳細數據。

ErrorResponse

錯誤回應

GrantType

用戶端用來要求存取令牌的授權授與形式。

TokenBodyParameterContract

OAuth 取得令牌要求本文參數 (www-url-form-encoded)。

AuthorizationMethod

授權端點支援的 HTTP 動詞。 GET 必須一律存在。 POST 是選擇性的。

Description
DELETE
GET
HEAD
OPTIONS
PATCH
POST
PUT
TRACE

AuthorizationServerContract

外部 OAuth 授權伺服器設定。

名稱 類型 Description
id

string

資源的完整資源標識碼。 例如 - /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

AuthorizationMethod[]

授權端點支援的 HTTP 動詞。 GET 必須一律存在。 POST 是選擇性的。

properties.bearerTokenSendingMethods

BearerTokenSendingMethod[]

指定將存取令牌傳遞至 API 的機制。

properties.clientAuthenticationMethod

ClientAuthenticationMethod[]

此授權伺服器的令牌端點所支持的驗證方法。 可能的值為 Basic 和/或 Body。 指定 Body 時,客戶端認證和其他參數會在 application/x-www-form-urlencoded 格式的要求本文內傳遞。

properties.clientId

string

向這個授權伺服器註冊的用戶端或應用程式標識碼。

properties.clientRegistrationEndpoint

string

執行此授權伺服器的用戶端或應用程式註冊頁面的選擇性參考。 包含所參考實體的絕對 URL。

properties.clientSecret

string

向這個授權伺服器註冊的用戶端或應用程式密碼。 此屬性不會填入 『GET』 作業! 使用 '/listSecrets' POST 要求來取得值。

properties.defaultScope

string

預設會要求存取令牌範圍。 可以在 API 層級覆寫。 應以包含空格分隔值的字串形式提供。

properties.description

string

授權伺服器的描述。 可以包含 HTML 格式標記。

properties.displayName

string

minLength: 1
maxLength: 50

使用者易記的授權伺服器名稱。

properties.grantTypes

GrantType[]

用戶端用來要求存取令牌的授權授與形式。

properties.resourceOwnerPassword

string

當此授權伺服器支援資源擁有者密碼授與類型時,可以選擇性地指定。 默認資源擁有者密碼。

properties.resourceOwnerUsername

string

當此授權伺服器支援資源擁有者密碼授與類型時,可以選擇性地指定。 默認資源擁有者用戶名稱。

properties.supportState

boolean

如果為 true,授權伺服器會包含授權要求到其回應的狀態參數。 用戶端可以使用狀態參數來提高通訊協定安全性。

properties.tokenBodyParameters

TokenBodyParameterContract[]

此授權伺服器的令牌端點所需的其他參數,以名稱與值字串屬性表示為 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 的機制。

Description
authorizationHeader
query

ClientAuthenticationMethod

此授權伺服器的令牌端點所支持的驗證方法。 可能的值為 Basic 和/或 Body。 指定 Body 時,客戶端認證和其他參數會在 application/x-www-form-urlencoded 格式的要求本文內傳遞。

Description
Basic

基本客戶端驗證方法。

Body

主體型驗證方法。

ErrorAdditionalInfo

資源管理錯誤其他資訊。

名稱 類型 Description
info

object

其他資訊。

type

string

其他信息類型。

ErrorDetail

錯誤詳細數據。

名稱 類型 Description
additionalInfo

ErrorAdditionalInfo[]

錯誤其他資訊。

code

string

錯誤碼。

details

ErrorDetail[]

錯誤詳細數據。

message

string

錯誤訊息。

target

string

錯誤目標。

ErrorResponse

錯誤回應

名稱 類型 Description
error

ErrorDetail

error 物件。

GrantType

用戶端用來要求存取令牌的授權授與形式。

Description
authorizationCode

授權碼授與流程,如 https://tools.ietf.org/html/rfc6749#section-4.1所述。

clientCredentials

客戶端認證授與流程,如 https://tools.ietf.org/html/rfc6749#section-4.4所述。

implicit

隱含程式代碼授與流程,如 https://tools.ietf.org/html/rfc6749#section-4.2所述。

resourceOwnerPassword

資源擁有者密碼授與流程,如 https://tools.ietf.org/html/rfc6749#section-4.3所述。

TokenBodyParameterContract

OAuth 取得令牌要求本文參數 (www-url-form-encoded)。

名稱 類型 Description
name

string

body 參數名稱。

value

string

body 參數值。