Creates or updates authorization provider.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}?api-version=2022-08-01
URI Parameters
Name |
In |
Required |
Type |
Description |
authorizationProviderId
|
path |
True
|
string
|
Identifier of the authorization provider.
Regex pattern: ^[^*#&+:<>?]+$
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group. The name is case insensitive.
|
serviceName
|
path |
True
|
string
|
The name of the API Management service.
Regex pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$
|
subscriptionId
|
path |
True
|
string
|
The ID of the target subscription.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Name |
Required |
Type |
Description |
If-Match
|
|
string
|
ETag of the Entity. Not required when creating an entity, but required when updating an entity.
|
Request Body
Name |
Type |
Description |
properties.displayName
|
string
|
Authorization Provider name. Must be 1 to 300 characters long.
|
properties.identityProvider
|
string
|
Identity provider name. Must be 1 to 300 characters long.
|
properties.oauth2
|
AuthorizationProviderOAuth2Settings
|
OAuth2 settings
|
Responses
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
ApiManagementCreateAuthorizationProviderAADAuthCode
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode?api-version=2022-08-01
{
"properties": {
"displayName": "aadwithauthcode",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "59790825-fdd3-4b10-bc7a-4c3aaf25801d",
"clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"scopes": "User.Read.All Group.Read.All",
"resourceUri": "https://graph.microsoft.com"
}
}
}
}
}
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2GrantTypes;
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2Settings;
import java.util.HashMap;
import java.util.Map;
/** Samples for AuthorizationProvider CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json
*/
/**
* Sample code: ApiManagementCreateAuthorizationProviderAADAuthCode.
*
* @param manager Entry point to ApiManagementManager.
*/
public static void apiManagementCreateAuthorizationProviderAADAuthCode(
com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
manager
.authorizationProviders()
.define("aadwithauthcode")
.withExistingService("rg1", "apimService1")
.withDisplayName("aadwithauthcode")
.withIdentityProvider("aad")
.withOauth2(
new AuthorizationProviderOAuth2Settings()
.withRedirectUrl("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1")
.withGrantTypes(
new AuthorizationProviderOAuth2GrantTypes()
.withAuthorizationCode(
mapOf(
"clientId",
"59790825-fdd3-4b10-bc7a-4c3aaf25801d",
"clientSecret",
"fakeTokenPlaceholder",
"resourceUri",
"https://graph.microsoft.com",
"scopes",
"User.Read.All Group.Read.All"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.apimanagement import ApiManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-apimanagement
# USAGE
python api_management_create_authorization_provider_aad_auth_code.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ApiManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.authorization_provider.create_or_update(
resource_group_name="rg1",
service_name="apimService1",
authorization_provider_id="aadwithauthcode",
parameters={
"properties": {
"displayName": "aadwithauthcode",
"identityProvider": "aad",
"oauth2": {
"grantTypes": {
"authorizationCode": {
"clientId": "59790825-fdd3-4b10-bc7a-4c3aaf25801d",
"clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"resourceUri": "https://graph.microsoft.com",
"scopes": "User.Read.All Group.Read.All",
}
},
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
}
},
)
print(response)
# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armapimanagement_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json
func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderAadAuthCode() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armapimanagement.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithauthcode", armapimanagement.AuthorizationProviderContract{
Properties: &armapimanagement.AuthorizationProviderContractProperties{
DisplayName: to.Ptr("aadwithauthcode"),
IdentityProvider: to.Ptr("aad"),
Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
AuthorizationCode: map[string]*string{
"clientId": to.Ptr("59790825-fdd3-4b10-bc7a-4c3aaf25801d"),
"clientSecret": to.Ptr("Q3iPSaKQ~fZFcJk5vKmqzUAfJagcJ8"),
"resourceUri": to.Ptr("https://graph.microsoft.com"),
"scopes": to.Ptr("User.Read.All Group.Read.All"),
},
},
RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
},
},
}, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{
// Name: to.Ptr("aadwithauthcode"),
// Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode"),
// Properties: &armapimanagement.AuthorizationProviderContractProperties{
// DisplayName: to.Ptr("aadwithauthcode"),
// IdentityProvider: to.Ptr("aad"),
// Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
// GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
// AuthorizationCode: map[string]*string{
// "clientId": to.Ptr("53790825-fdd3-4b80-bc7a-4c3aaf25801d"),
// "loginUri": to.Ptr("https://login.windows.net"),
// "resourceUri": to.Ptr("https://graph.microsoft.com"),
// "scopes": to.Ptr("User.Read.All Group.Read.All"),
// "tenantId": to.Ptr("common"),
// },
// },
// RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ApiManagementClient } = require("@azure/arm-apimanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates authorization provider.
*
* @summary Creates or updates authorization provider.
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json
*/
async function apiManagementCreateAuthorizationProviderAadAuthCode() {
const subscriptionId = process.env["APIMANAGEMENT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["APIMANAGEMENT_RESOURCE_GROUP"] || "rg1";
const serviceName = "apimService1";
const authorizationProviderId = "aadwithauthcode";
const parameters = {
displayName: "aadwithauthcode",
identityProvider: "aad",
oauth2: {
grantTypes: {
authorizationCode: {
clientId: "",
clientSecret: "",
resourceUri: "https://graph.microsoft.com",
scopes: "User.Read.All Group.Read.All",
},
},
redirectUrl:
"https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
};
const credential = new DefaultAzureCredential();
const client = new ApiManagementClient(credential, subscriptionId);
const result = await client.authorizationProvider.createOrUpdate(
resourceGroupName,
serviceName,
authorizationProviderId,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "aadwithauthcode",
"properties": {
"displayName": "aadwithauthcode",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "53790825-fdd3-4b80-bc7a-4c3aaf25801d",
"scopes": "User.Read.All Group.Read.All",
"loginUri": "https://login.windows.net",
"resourceUri": "https://graph.microsoft.com",
"tenantId": "common"
}
}
}
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithauthcode",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "aadwithauthcode",
"properties": {
"displayName": "aadwithauthcode",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "53790825-fdd3-4b80-bc7a-4c3aaf25801d",
"scopes": "User.Read.All Group.Read.All",
"loginUri": "https://login.windows.net",
"resourceUri": "https://graph.microsoft.com",
"tenantId": "common"
}
}
}
}
}
ApiManagementCreateAuthorizationProviderAADClientCred
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred?api-version=2022-08-01
{
"properties": {
"displayName": "aadwithclientcred",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"scopes": "User.Read.All Group.Read.All",
"resourceUri": "https://graph.microsoft.com"
}
}
}
}
}
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2GrantTypes;
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2Settings;
import java.util.HashMap;
import java.util.Map;
/** Samples for AuthorizationProvider CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json
*/
/**
* Sample code: ApiManagementCreateAuthorizationProviderAADClientCred.
*
* @param manager Entry point to ApiManagementManager.
*/
public static void apiManagementCreateAuthorizationProviderAADClientCred(
com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
manager
.authorizationProviders()
.define("aadwithclientcred")
.withExistingService("rg1", "apimService1")
.withDisplayName("aadwithclientcred")
.withIdentityProvider("aad")
.withOauth2(
new AuthorizationProviderOAuth2Settings()
.withRedirectUrl("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1")
.withGrantTypes(
new AuthorizationProviderOAuth2GrantTypes()
.withAuthorizationCode(
mapOf(
"resourceUri",
"https://graph.microsoft.com",
"scopes",
"User.Read.All Group.Read.All"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.apimanagement import ApiManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-apimanagement
# USAGE
python api_management_create_authorization_provider_aad_client_cred.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ApiManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.authorization_provider.create_or_update(
resource_group_name="rg1",
service_name="apimService1",
authorization_provider_id="aadwithclientcred",
parameters={
"properties": {
"displayName": "aadwithclientcred",
"identityProvider": "aad",
"oauth2": {
"grantTypes": {
"authorizationCode": {
"resourceUri": "https://graph.microsoft.com",
"scopes": "User.Read.All Group.Read.All",
}
},
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
}
},
)
print(response)
# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armapimanagement_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json
func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderAadClientCred() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armapimanagement.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "aadwithclientcred", armapimanagement.AuthorizationProviderContract{
Properties: &armapimanagement.AuthorizationProviderContractProperties{
DisplayName: to.Ptr("aadwithclientcred"),
IdentityProvider: to.Ptr("aad"),
Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
AuthorizationCode: map[string]*string{
"resourceUri": to.Ptr("https://graph.microsoft.com"),
"scopes": to.Ptr("User.Read.All Group.Read.All"),
},
},
RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
},
},
}, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{
// Name: to.Ptr("aadwithclientcred"),
// Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred"),
// Properties: &armapimanagement.AuthorizationProviderContractProperties{
// DisplayName: to.Ptr("aadwithclientcred"),
// IdentityProvider: to.Ptr("aad"),
// Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
// GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
// ClientCredentials: map[string]*string{
// "loginUri": to.Ptr("https://login.windows.net"),
// "resourceUri": to.Ptr("https://graph.microsoft.com"),
// "scopes": to.Ptr("User.Read.All Group.Read.All"),
// "tenantId": to.Ptr("common"),
// },
// },
// RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ApiManagementClient } = require("@azure/arm-apimanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates authorization provider.
*
* @summary Creates or updates authorization provider.
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json
*/
async function apiManagementCreateAuthorizationProviderAadClientCred() {
const subscriptionId = process.env["APIMANAGEMENT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["APIMANAGEMENT_RESOURCE_GROUP"] || "rg1";
const serviceName = "apimService1";
const authorizationProviderId = "aadwithclientcred";
const parameters = {
displayName: "aadwithclientcred",
identityProvider: "aad",
oauth2: {
grantTypes: {
authorizationCode: {
resourceUri: "https://graph.microsoft.com",
scopes: "User.Read.All Group.Read.All",
},
},
redirectUrl:
"https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
};
const credential = new DefaultAzureCredential();
const client = new ApiManagementClient(credential, subscriptionId);
const result = await client.authorizationProvider.createOrUpdate(
resourceGroupName,
serviceName,
authorizationProviderId,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "aadwithclientcred",
"properties": {
"displayName": "aadwithclientcred",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"clientCredentials": {
"scopes": "User.Read.All Group.Read.All",
"loginUri": "https://login.windows.net",
"resourceUri": "https://graph.microsoft.com",
"tenantId": "common"
}
}
}
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/aadwithclientcred",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "aadwithclientcred",
"properties": {
"displayName": "aadwithclientcred",
"identityProvider": "aad",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"clientCredentials": {
"scopes": "User.Read.All Group.Read.All",
"loginUri": "https://login.windows.net",
"resourceUri": "https://graph.microsoft.com",
"tenantId": "common"
}
}
}
}
}
ApiManagementCreateAuthorizationProviderGenericOAuth2
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite?api-version=2022-08-01
{
"properties": {
"displayName": "eventbrite",
"identityProvider": "oauth2",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "genericClientId",
"clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"scopes": "",
"authorizationUrl": "https://www.eventbrite.com/oauth/authorize",
"refreshUrl": "https://www.eventbrite.com/oauth/token",
"tokenUrl": "https://www.eventbrite.com/oauth/token"
}
}
}
}
}
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2GrantTypes;
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2Settings;
import java.util.HashMap;
import java.util.Map;
/** Samples for AuthorizationProvider CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json
*/
/**
* Sample code: ApiManagementCreateAuthorizationProviderGenericOAuth2.
*
* @param manager Entry point to ApiManagementManager.
*/
public static void apiManagementCreateAuthorizationProviderGenericOAuth2(
com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
manager
.authorizationProviders()
.define("eventbrite")
.withExistingService("rg1", "apimService1")
.withDisplayName("eventbrite")
.withIdentityProvider("oauth2")
.withOauth2(
new AuthorizationProviderOAuth2Settings()
.withRedirectUrl("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1")
.withGrantTypes(
new AuthorizationProviderOAuth2GrantTypes()
.withAuthorizationCode(
mapOf(
"authorizationUrl",
"fakeTokenPlaceholder",
"clientId",
"ZYIJTBTABHOUQQDLZY",
"clientSecret",
"fakeTokenPlaceholder",
"refreshUrl",
"https://www.eventbrite.com/oauth/token",
"scopes",
"",
"tokenUrl",
"fakeTokenPlaceholder"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.apimanagement import ApiManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-apimanagement
# USAGE
python api_management_create_authorization_provider_generic_oauth2.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ApiManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.authorization_provider.create_or_update(
resource_group_name="rg1",
service_name="apimService1",
authorization_provider_id="eventbrite",
parameters={
"properties": {
"displayName": "eventbrite",
"identityProvider": "oauth2",
"oauth2": {
"grantTypes": {
"authorizationCode": {
"authorizationUrl": "https://www.eventbrite.com/oauth/authorize",
"clientId": "genericClientId",
"clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"refreshUrl": "https://www.eventbrite.com/oauth/token",
"scopes": "",
"tokenUrl": "https://www.eventbrite.com/oauth/token",
}
},
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
}
},
)
print(response)
# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armapimanagement_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json
func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderGenericOAuth2() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armapimanagement.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "eventbrite", armapimanagement.AuthorizationProviderContract{
Properties: &armapimanagement.AuthorizationProviderContractProperties{
DisplayName: to.Ptr("eventbrite"),
IdentityProvider: to.Ptr("oauth2"),
Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
AuthorizationCode: map[string]*string{
"authorizationUrl": to.Ptr("https://www.eventbrite.com/oauth/authorize"),
"clientId": to.Ptr("ZYIJTBTABHOUQQDLZY"),
"clientSecret": to.Ptr("Q3iPSaKQ~fZFcJk5vKmqzUAfJagcJ8"),
"refreshUrl": to.Ptr("https://www.eventbrite.com/oauth/token"),
"scopes": nil,
"tokenUrl": to.Ptr("https://www.eventbrite.com/oauth/token"),
},
},
RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
},
},
}, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{
// Name: to.Ptr("eventbrite"),
// Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite"),
// Properties: &armapimanagement.AuthorizationProviderContractProperties{
// DisplayName: to.Ptr("eventbrite"),
// IdentityProvider: to.Ptr("oauth2"),
// Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
// GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
// AuthorizationCode: map[string]*string{
// "authorizationUrl": to.Ptr("https://www.eventbrite.com/oauth/authorize"),
// "clientId": to.Ptr("ZYIJTBTABHOUQQDLZY"),
// "refreshUrl": to.Ptr("https://www.eventbrite.com/oauth/token"),
// "scopes": nil,
// "tokenUrl": to.Ptr("https://www.eventbrite.com/oauth/token"),
// },
// },
// RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ApiManagementClient } = require("@azure/arm-apimanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates authorization provider.
*
* @summary Creates or updates authorization provider.
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json
*/
async function apiManagementCreateAuthorizationProviderGenericOAuth2() {
const subscriptionId = process.env["APIMANAGEMENT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["APIMANAGEMENT_RESOURCE_GROUP"] || "rg1";
const serviceName = "apimService1";
const authorizationProviderId = "eventbrite";
const parameters = {
displayName: "eventbrite",
identityProvider: "oauth2",
oauth2: {
grantTypes: {
authorizationCode: {
authorizationUrl: "https://www.eventbrite.com/oauth/authorize",
clientId: "",
clientSecret: "",
refreshUrl: "https://www.eventbrite.com/oauth/token",
scopes: "",
tokenUrl: "https://www.eventbrite.com/oauth/token",
},
},
redirectUrl:
"https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
};
const credential = new DefaultAzureCredential();
const client = new ApiManagementClient(credential, subscriptionId);
const result = await client.authorizationProvider.createOrUpdate(
resourceGroupName,
serviceName,
authorizationProviderId,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "eventbrite",
"properties": {
"displayName": "eventbrite",
"identityProvider": "oauth2",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "genericClientId",
"scopes": "",
"authorizationUrl": "https://www.eventbrite.com/oauth/authorize",
"refreshUrl": "https://www.eventbrite.com/oauth/token",
"tokenUrl": "https://www.eventbrite.com/oauth/token"
}
}
}
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/eventbrite",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "eventbrite",
"properties": {
"displayName": "eventbrite",
"identityProvider": "oauth2",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "genericClientId",
"scopes": "",
"authorizationUrl": "https://www.eventbrite.com/oauth/authorize",
"refreshUrl": "https://www.eventbrite.com/oauth/token",
"tokenUrl": "https://www.eventbrite.com/oauth/token"
}
}
}
}
}
ApiManagementCreateAuthorizationProviderOOBGoogle
Sample Request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google?api-version=2022-08-01
{
"properties": {
"displayName": "google",
"identityProvider": "google",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"clientSecret": "XXXXXXXXXXXXXXXXXXXX",
"scopes": "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}
}
}
}
}
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2GrantTypes;
import com.azure.resourcemanager.apimanagement.models.AuthorizationProviderOAuth2Settings;
import java.util.HashMap;
import java.util.Map;
/** Samples for AuthorizationProvider CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json
*/
/**
* Sample code: ApiManagementCreateAuthorizationProviderOOBGoogle.
*
* @param manager Entry point to ApiManagementManager.
*/
public static void apiManagementCreateAuthorizationProviderOOBGoogle(
com.azure.resourcemanager.apimanagement.ApiManagementManager manager) {
manager
.authorizationProviders()
.define("google")
.withExistingService("rg1", "apimService1")
.withDisplayName("google")
.withIdentityProvider("google")
.withOauth2(
new AuthorizationProviderOAuth2Settings()
.withRedirectUrl("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1")
.withGrantTypes(
new AuthorizationProviderOAuth2GrantTypes()
.withAuthorizationCode(
mapOf(
"clientId",
"508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com",
"clientSecret",
"fakeTokenPlaceholder",
"scopes",
"openid https://www.googleapis.com/auth/userinfo.profile"
+ " https://www.googleapis.com/auth/userinfo.email"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.apimanagement import ApiManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-apimanagement
# USAGE
python api_management_create_authorization_provider_oob_google.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ApiManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.authorization_provider.create_or_update(
resource_group_name="rg1",
service_name="apimService1",
authorization_provider_id="google",
parameters={
"properties": {
"displayName": "google",
"identityProvider": "google",
"oauth2": {
"grantTypes": {
"authorizationCode": {
"clientId": "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"clientSecret": "XXXXXXXXXXXXXXXXXXXX",
"scopes": "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
}
},
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
}
},
)
print(response)
# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armapimanagement_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json
func ExampleAuthorizationProviderClient_CreateOrUpdate_apiManagementCreateAuthorizationProviderOobGoogle() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armapimanagement.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAuthorizationProviderClient().CreateOrUpdate(ctx, "rg1", "apimService1", "google", armapimanagement.AuthorizationProviderContract{
Properties: &armapimanagement.AuthorizationProviderContractProperties{
DisplayName: to.Ptr("google"),
IdentityProvider: to.Ptr("google"),
Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
AuthorizationCode: map[string]*string{
"clientId": to.Ptr("508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com"),
"clientSecret": to.Ptr("qDN0VyVFjU1OsOyT5Kz8ce"),
"scopes": to.Ptr("openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"),
},
},
RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
},
},
}, &armapimanagement.AuthorizationProviderClientCreateOrUpdateOptions{IfMatch: nil})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.AuthorizationProviderContract = armapimanagement.AuthorizationProviderContract{
// Name: to.Ptr("google"),
// Type: to.Ptr("Microsoft.ApiManagement/service/authorizationProviders"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google"),
// Properties: &armapimanagement.AuthorizationProviderContractProperties{
// DisplayName: to.Ptr("google"),
// IdentityProvider: to.Ptr("google"),
// Oauth2: &armapimanagement.AuthorizationProviderOAuth2Settings{
// GrantTypes: &armapimanagement.AuthorizationProviderOAuth2GrantTypes{
// AuthorizationCode: map[string]*string{
// "clientId": to.Ptr("508791967882-5qv6o2i99a75un7329vlegtk78kr766h.apps.googleusercontent.com"),
// "scopes": to.Ptr("openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"),
// },
// },
// RedirectURL: to.Ptr("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ApiManagementClient } = require("@azure/arm-apimanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates authorization provider.
*
* @summary Creates or updates authorization provider.
* x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2022-08-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json
*/
async function apiManagementCreateAuthorizationProviderOobGoogle() {
const subscriptionId = process.env["APIMANAGEMENT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["APIMANAGEMENT_RESOURCE_GROUP"] || "rg1";
const serviceName = "apimService1";
const authorizationProviderId = "google";
const parameters = {
displayName: "google",
identityProvider: "google",
oauth2: {
grantTypes: {
authorizationCode: {
clientId: "",
clientSecret: "",
scopes:
"openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
},
},
redirectUrl:
"https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
},
};
const credential = new DefaultAzureCredential();
const client = new ApiManagementClient(credential, subscriptionId);
const result = await client.authorizationProvider.createOrUpdate(
resourceGroupName,
serviceName,
authorizationProviderId,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "google",
"properties": {
"displayName": "google",
"identityProvider": "google",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"scopes": "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}
}
}
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/authorizationProviders/google",
"type": "Microsoft.ApiManagement/service/authorizationProviders",
"name": "google",
"properties": {
"displayName": "google",
"identityProvider": "google",
"oauth2": {
"redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1",
"grantTypes": {
"authorizationCode": {
"clientId": "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"scopes": "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
}
}
}
}
}
Definitions
AuthorizationProviderContract
Authorization Provider contract.
Name |
Type |
Description |
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
The name of the resource
|
properties.displayName
|
string
|
Authorization Provider name. Must be 1 to 300 characters long.
|
properties.identityProvider
|
string
|
Identity provider name. Must be 1 to 300 characters long.
|
properties.oauth2
|
AuthorizationProviderOAuth2Settings
|
OAuth2 settings
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
AuthorizationProviderOAuth2GrantTypes
Authorization Provider oauth2 grant types settings
Name |
Type |
Description |
authorizationCode
|
object
|
OAuth2 authorization code grant parameters
|
clientCredentials
|
object
|
OAuth2 client credential grant parameters
|
AuthorizationProviderOAuth2Settings
OAuth2 settings details
ErrorFieldContract
Error Field contract.
Name |
Type |
Description |
code
|
string
|
Property level error code.
|
message
|
string
|
Human-readable representation of property-level error.
|
target
|
string
|
Property name.
|
ErrorResponse
Error Response.
Name |
Type |
Description |
error.code
|
string
|
Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.
|
error.details
|
ErrorFieldContract[]
|
The list of invalid fields send in request, in case of validation error.
|
error.message
|
string
|
Human-readable representation of the error.
|