Skip to content

Commit

Permalink
Allow authentication for ApplicationTokenCredentials for profiles (#2386
Browse files Browse the repository at this point in the history
)
  • Loading branch information
viananth authored and jianghaolu committed Sep 13, 2018
1 parent c0c2e87 commit 6de3bc5
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.microsoft.azure.AzureResponseBuilder;
import com.microsoft.azure.arm.resources.AzureConfigurable;
import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl;
import com.microsoft.azure.arm.utils.ResourceManagerThrottlingInterceptor;
import com.microsoft.azure.credentials.ApplicationTokenCredentials;
import com.microsoft.azure.credentials.AzureTokenCredentials;
import com.microsoft.azure.management.appservice.v2016_03_01.BillingMeters;
import com.microsoft.azure.management.appservice.v2016_03_01.Certificates;
Expand Down Expand Up @@ -76,6 +78,7 @@
import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworkGateways;
import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworkPeerings;
import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworks;
import com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor;
import com.microsoft.azure.management.resources.v2018_02_01.DeploymentOperations;
import com.microsoft.azure.management.resources.v2018_02_01.Deployments;
import com.microsoft.azure.management.resources.v2018_02_01.Providers;
Expand Down Expand Up @@ -123,6 +126,18 @@ public static Azure authenticate(AzureTokenCredentials credentials, String subsc
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.build(), subscriptionId);
}

public static Azure authenticate(ApplicationTokenCredentials credentials, String subscriptionId) {
return new Azure(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withInterceptor(new ProviderRegistrationInterceptor(credentials))
.withInterceptor(new ResourceManagerThrottlingInterceptor())
.build(), subscriptionId);
}

/**
* Creates an instance of Azure that exposes ContainerService resource management API entry points.
*
Expand Down

0 comments on commit 6de3bc5

Please sign in to comment.