public AzureActiveDirectoryHelper(AzureActiveDirectoryConfig configuration)
        {
            var token = GetAuthorizationHeader(configuration);
            var cred  = new TokenCloudCredentials(configuration.azureSubscriptionID, token);

            client = new WebSiteManagementClient(cred, APIENDPOINT);
        }
        private string GetAuthorizationHeader(AzureActiveDirectoryConfig configguration)
        {
            AuthenticationResult result = null;

            var context = new AuthenticationContext("https://login.windows.net/" + configguration.addTenant);

            var thread = new Thread(
                () => { result = context.AcquireToken(resource: configguration.aadResourceURI, clientId: configguration.addClientID, redirectUri: new Uri(configguration.aadRedirectURL), promptBehavior: PromptBehavior.Always); }
                );

            thread.SetApartmentState(ApartmentState.STA);
            thread.Name = "AcquiereTokenThread";
            thread.Start();
            thread.Join();

            return(result.CreateAuthorizationHeader().Substring("Bearer ".Length));
        }
        private string GetAuthorizationHeader(AzureActiveDirectoryConfig configguration)
        {
            AuthenticationResult result = null;

            var context = new AuthenticationContext("https://login.windows.net/" + configguration.addTenant);

            var thread = new Thread(
                () => { result = context.AcquireToken(resource: configguration.aadResourceURI, clientId: configguration.addClientID, redirectUri: new Uri(configguration.aadRedirectURL), promptBehavior: PromptBehavior.Always); }
                );

            thread.SetApartmentState(ApartmentState.STA);
            thread.Name = "AcquiereTokenThread";
            thread.Start();
            thread.Join();

            return result.CreateAuthorizationHeader().Substring("Bearer ".Length);
        }
 public AzureActiveDirectoryHelper(AzureActiveDirectoryConfig configuration)
 {
     var token = GetAuthorizationHeader(configuration);
     var cred = new TokenCloudCredentials(configuration.azureSubscriptionID, token);
     client = new WebSiteManagementClient(cred, APIENDPOINT);
 }