Forum Discussion
BazVanDenDungen
May 20, 2022Copper Contributor
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?
- Sayali-MSFT
Microsoft
BazVanDenDungen-Please have look into this-
1.https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/add-authentication?tabs=dotnet%2Cdotnet-sample
2.https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-authentication?view=azure-bot-service-4.0
hope it's helpful.- Sayali-MSFT
Microsoft
BazVanDenDungen-Could you please confirm if your issue has resolved with above suggestion or still looking for any help?- BazVanDenDungenCopper Contributor
Sayali-MSFT We managed to get our integration working by modifying our oath connection setting from api://<guid> to api://<guid>/access_as_user
The only thing we are missing now is that our jwt token appears to be missing the email address associated with the user.
- Sayali-MSFT
Microsoft
BazVanDenDungen-We are looking into this I will get back to you soon.