Forum Discussion

BazVanDenDungen's avatar
BazVanDenDungen
Copper Contributor
May 20, 2022

How do I get my teams bot to authenticate to a web service

I have a teams bot which I want to use as an interface for my service stack webservice however the token I have access to is not being accepted by the web service. 

 

I followed the "AAD SSO for tabs and message extension" tutorial to set up my Azure instance and get a basic bot up and running. When I modified the query handler to send a request to a web service with the token provided it is responding with a login page.

 

This is the code that I added to the Simple Graph Client in a new method which passes in what the user types as query

 

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://<my website>/api/ws/v1/search?query=" + query);
request.Headers.Add("Authorization", "Bearer " + _token);
request.Method = "GET";

request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

using (System.Net.HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
    return reader.ReadToEnd();
}

 

 

Do I need to make use of a shared certificate? or is there some additional configuration that I have missed which is necessary to make this situation work?

Resources