private async void getToken() { authContext = new AuthenticationContext(authority); AuthenticationResult authResult = authContext.AcquireToken(apiResourceId, clientId, redirectUri); string token = authResult.AccessToken; //httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); //HttpResponseMessage response = await httpClient.GetAsync(apiBaseAddress + "/api/values"); //string responseString = await response.Content.ReadAsStringAsync(); //Console.WriteLine("Response = " , responseString); PortalApiApp apiapp = new PortalApiApp(); apiapp.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); var res1 = apiapp.Values.Get(); var res2 = apiapp.Values.GetById(1); Console.WriteLine("response=" , res1); }
private async void getToken() { authContext = new AuthenticationContext(authority); AuthenticationResult authResult = authContext.AcquireToken(apiResourceId, clientId, redirectUri); string token = authResult.AccessToken; //httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); //HttpResponseMessage response = await httpClient.GetAsync(apiBaseAddress + "/api/values"); //string responseString = await response.Content.ReadAsStringAsync(); //Console.WriteLine("Response = " , responseString); PortalApiApp apiapp = new PortalApiApp(); apiapp.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); var res1 = apiapp.Values.Get(); var res2 = apiapp.Values.GetById(1); Console.WriteLine("response=", res1); }