private void AddHeaders(HttpClient requestClient, string jwt, bool IsCsv) { string bearerTokenHeader = BearerToken.FromJwt(jwt).BearerTokenHeader; requestClient.DefaultRequestHeaders.Clear(); if (IsCsv) { requestClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/plaintext")); } else { requestClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); } requestClient.DefaultRequestHeaders.Add("authorization", bearerTokenHeader); requestClient.DefaultRequestHeaders.Add("api-version", "1.0"); }
private void initSettings() { updateStatus("Initializing settings ...", true); Settings curAppSettings = Settings.Default; //eaTestKeyLnk.Links.Add(new LinkLabel.Link() { LinkData = curAppSettings.TestEnrollmentKeyUrl }); string ujwt = curAppSettings["AccessKeyUsage"]?.ToString(); if (!string.IsNullOrEmpty(ujwt)) { currentToken = BearerToken.FromJwt(ujwt); accessKeyUsageTxt.Text = currentToken.Token; currentConfig.UsageAccessKey = currentToken.Token; } string pjwt = curAppSettings["AccessKeyPricing"]?.ToString(); if (!string.IsNullOrEmpty(pjwt)) { currentToken = BearerToken.FromJwt(pjwt); accessKeyPriceTxt.Text = currentToken.Token; currentConfig.PricingAccessKey = currentToken.Token; } else { currentConfig.PricingAccessKey = currentConfig.UsageAccessKey; } currentConfig.EnrollmentNumber = curAppSettings["EnrollmentNumber"]?.ToString(); if (!string.IsNullOrEmpty(currentConfig.EnrollmentNumber)) { enrollmentTx.Text = currentConfig.EnrollmentNumber; } currentConfig.Region = curAppSettings["DefaultRegion"]?.ToString(); if (!string.IsNullOrEmpty(currentConfig.Region)) { enrollmentTx.Text = currentConfig.Region; } else { //Set a default region currentConfig.Region = RuntimeConstants.DefaultAzureRegion; } currentConfig.SubscriptionId = curAppSettings["SubscriptionId"]?.ToString(); eaSubscriptionIdTxt.Text = currentConfig.SubscriptionId; currentConfig.TenantId = curAppSettings["AADtenantId"]?.ToString(); azureTenantIdTxt.Text = currentConfig.TenantId; currentConfig.ClientId = curAppSettings["AADClientId"]?.ToString(); azureClientIdTxt.Text = currentConfig.ClientId; currentConfig.SharedSecret = curAppSettings["AADClientSecret"]?.ToString(); azureSharedSecretTxt.Text = currentConfig.SharedSecret; currentConfig.ManagementTokenAudience = curAppSettings["ManagementTokenAudience"]?.ToString(); bindOfferCodes(); updateStatus("Settings initialized ..."); }