HttpClientEx.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Net.Http;
5 using System.Net.Http.Headers;
6 using System.Text;
7 using System.Threading.Tasks;
8 
9 namespace Microsoft.Bot.Connector
10 {
11  public static class HttpClientEx
12  {
20  public static async Task AddAPIAuthorization(this HttpClient client, string appId = null, string password = null)
21  {
22  var token = await new MicrosoftAppCredentials(appId, password).GetTokenAsync();
23  client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
24  }
25  }
26 }
async Task< string > GetTokenAsync(bool forceRefresh=false)
static async Task AddAPIAuthorization(this HttpClient client, string appId=null, string password=null)
add Bearer authorization token for making API calls
Definition: HttpClientEx.cs:20