Condividi tramite


Authorization - Create Or Update

Crea o aggiorna l'autorizzazione.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}?api-version=2024-05-01

Parametri dell'URI

Nome In Necessario Tipo Descrizione
authorizationId
path True

string

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

Identificatore dell'autorizzazione.

authorizationProviderId
path True

string

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

Identificatore del provider di autorizzazione.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

Nome del gruppo di risorse. Il nome non fa distinzione tra maiuscole e minuscole.

serviceName
path True

string

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

Nome del servizio Gestione API.

subscriptionId
path True

string (uuid)

ID della sottoscrizione di destinazione. Il valore deve essere un UUID.

api-version
query True

string

minLength: 1

Versione dell'API da usare per questa operazione.

Intestazione della richiesta

Nome Necessario Tipo Descrizione
If-Match

string

ETag dell'entità. Non obbligatorio durante la creazione di un'entità, ma necessario durante l'aggiornamento di un'entità.

Corpo della richiesta

Nome Tipo Descrizione
properties.authorizationType

AuthorizationType

Opzioni del tipo di autorizzazione

properties.error

AuthorizationError

properties.oauth2grantType

OAuth2GrantType

Opzioni del tipo di concessione OAuth2

properties.parameters

object

Parametri di autorizzazione

properties.status

string

Stato dell'autorizzazione

Risposte

Nome Tipo Descrizione
200 OK

AuthorizationContract

L'autorizzazione esistente è stata aggiornata correttamente.

Intestazioni

ETag: string

201 Created

AuthorizationContract

L'autorizzazione è stata creata correttamente.

Intestazioni

ETag: string

Other Status Codes

ErrorResponse

Risposta di errore che descrive il motivo per cui l'operazione non è riuscita.

Sicurezza

azure_auth

Flusso OAuth2 di Azure Active Directory.

Tipo: oauth2
Flow: implicit
URL di autorizzazione: https://login.microsoftonline.com/common/oauth2/authorize

Ambiti

Nome Descrizione
user_impersonation rappresentare l'account utente

Esempio

ApiManagementCreateAuthorizationAADAuthCode
ApiManagementCreateAuthorizationAADClientCred

ApiManagementCreateAuthorizationAADAuthCode

Esempio di richiesta

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz2?api-version=2024-05-01

{
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "AuthorizationCode"
  }
}

Risposta di esempio

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz2",
  "type": "Microsoft.ApiManagement/service/authorizationProviders/authorizations",
  "name": "authz2",
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "AuthorizationCode",
    "status": "Error",
    "error": {
      "code": "Unauthenticated",
      "message": "This connection is not authenticated."
    }
  }
}
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode/authorizations/authz2",
  "type": "Microsoft.ApiManagement/service/authorizationProviders/authorizations",
  "name": "authz2",
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "AuthorizationCode",
    "status": "Error",
    "error": {
      "code": "Unauthenticated",
      "message": "This connection is not authenticated."
    }
  }
}

ApiManagementCreateAuthorizationAADClientCred

Esempio di richiesta

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz1?api-version=2024-05-01

{
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "AuthorizationCode",
    "parameters": {
      "clientId": "clientsecretid",
      "clientSecret": "clientsecretvalue"
    }
  }
}

Risposta di esempio

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz1",
  "type": "Microsoft.ApiManagement/service/authorizationProviders/authorizations",
  "name": "authz1",
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "ClientCredentials",
    "parameters": {
      "clientId": "clientsecretid"
    },
    "status": "Connected"
  }
}
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred/authorizations/authz1",
  "type": "Microsoft.ApiManagement/service/authorizationProviders/authorizations",
  "name": "authz1",
  "properties": {
    "authorizationType": "OAuth2",
    "oauth2grantType": "ClientCredentials",
    "parameters": {
      "clientId": "clientsecretid"
    },
    "status": "Connected"
  }
}

Definizioni

Nome Descrizione
AuthorizationContract

Contratto di autorizzazione.

AuthorizationError

Dettagli dell'errore di autorizzazione.

AuthorizationType

Opzioni del tipo di autorizzazione

ErrorAdditionalInfo

Informazioni aggiuntive sull'errore di gestione delle risorse.

ErrorDetail

Dettagli dell'errore.

ErrorResponse

Risposta di errore

OAuth2GrantType

Opzioni del tipo di concessione OAuth2

AuthorizationContract

Contratto di autorizzazione.

Nome Tipo Descrizione
id

string

ID risorsa completo per la risorsa. Ad esempio - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

Nome della risorsa

properties.authorizationType

AuthorizationType

Opzioni del tipo di autorizzazione

properties.error

AuthorizationError

properties.oauth2grantType

OAuth2GrantType

Opzioni del tipo di concessione OAuth2

properties.parameters

object

Parametri di autorizzazione

properties.status

string

Stato dell'autorizzazione

type

string

Tipo della risorsa. Ad esempio, "Microsoft.Compute/virtualMachines" o "Microsoft.Storage/storageAccounts"

AuthorizationError

Dettagli dell'errore di autorizzazione.

Nome Tipo Descrizione
code

string

Codice di errore

message

string

Messaggio di errore

AuthorizationType

Opzioni del tipo di autorizzazione

Valore Descrizione
OAuth2

Tipo di autorizzazione OAuth2

ErrorAdditionalInfo

Informazioni aggiuntive sull'errore di gestione delle risorse.

Nome Tipo Descrizione
info

object

Informazioni aggiuntive.

type

string

Tipo di informazioni aggiuntive.

ErrorDetail

Dettagli dell'errore.

Nome Tipo Descrizione
additionalInfo

ErrorAdditionalInfo[]

Informazioni aggiuntive sull'errore.

code

string

Codice di errore.

details

ErrorDetail[]

Dettagli dell'errore.

message

string

Messaggio di errore.

target

string

Destinazione dell'errore.

ErrorResponse

Risposta di errore

Nome Tipo Descrizione
error

ErrorDetail

Oggetto error.

OAuth2GrantType

Opzioni del tipo di concessione OAuth2

Valore Descrizione
AuthorizationCode

Concessione del codice di autorizzazione

ClientCredentials

Concessione di credenziali client