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

Copper Contributor

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?

7 Replies
@BazVanDenDungen-We are looking into this I will get back to you soon.
@BazVanDenDungen-Could you please confirm if your issue has resolved with above suggestion or still looking for any help?

@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.

@BazVanDenDungen-When a user asks the bot to do something that requires the bot to have the user logged in, the bot can use an OAuthPrompt to initiate retrieving a token for a given connection.When you start an OAuth prompt, it waits for a token response event, from which it will retrieve the user's token.
Ref Doc:-Add authentication to a bot in Bot Framework SDK - Bot Service | Microsoft Docs

Could you please confirm if your issue has resolved with above suggestion or still looking for any help?

@Sayali-MSFT We were able to resolve our issue thanks