botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

BotAuthentication problem

Open vovanb opened this issue 10 years ago • 8 comments

Hello, I have two question regarding BotAuthentication: 1.I created OWIN host selfservice project(windows service) which handle BOT controller located in separated C# class library.How I can pass programmatically MicrosoftAppId and MicrosoftAppPassword to dll, because by default it is looking in host exe app config and not in folder where dll placed. 2.We want to develop BOT service which will serve multiple BOTS, different by incoming laguage for example in same service - how we can load Microsoft.Bot.Connector with different credential ? Thanks a lot.

vovanb avatar Aug 01 '16 07:08 vovanb

  1. You can pass parameters to BotAuthentication attribute rather than assuming the presence of an app.config: https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Connector/BotAuthentication.cs#L15
  2. You can have different endpoints per bot, for example.

willportnoy avatar Aug 01 '16 21:08 willportnoy

@vovanb In regards to bullet 2 - I had a similar problem when I developed skype calling bot. I had to implement 1 service that will be used for several bots, all of them executing the same logic but producing different experience. For this purpose, in each bot definition, I appended query string parameter to the calling URL (in your case this would be messaging URL). However, the SDK v3 did not support URL query string parameters, so I created pull request #764 to implement the support. So in your case you might consider identical aproach to add something like ?lang=EN or ?lang=FR to the messaging URL.

urmich avatar Aug 02 '16 07:08 urmich

@willportnoy and @mghimp thanks for the reply. But how I can pass MicrosoftAppId and MicrosoftAppPassword in runtime, can you provide example? As soon as I know there is no way to assign attribute metadata in runtime - it is done on compilation. Also if I will have different endpoint for bot then Authentication MicrosoftAppId should be different for each bot -since it is uneq cross the framework (I got error when tried to use same MicrosoftAppId for different bot) Thanks

vovanb avatar Aug 02 '16 07:08 vovanb

@vovanb you may want to search for how people create a dynamic ActionFilterAttribute - for example, you want want to create your own attribute that wraps and delegates to the framework's BotAuthentication attribute and provides the values dynamically but delegates to the inner BotAuthentication.OnActionExecutingAsync method.

willportnoy avatar Aug 02 '16 15:08 willportnoy

Ok thank you, can you provide an example?

Sincerely, Vladimir

On 2 באוג׳ 2016, at 18:56, Will Portnoy [email protected] wrote:

@vovanb you may want to search for how people create a dynamic ActionFilterAttribute - for example, you want want to create your own attribute that wraps and delegates to the framework's BotAuthentication attribute and provides the values dynamically but delegates to the inner BotAuthentication.OnActionExecutingAsync method.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

vovanb avatar Aug 02 '16 17:08 vovanb

I don't have any example code handy, but you may want to look at https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Connector/BotAuthentication.cs#L15 as a model for implementing an ActionFilterAttribute. In your implementation of ActionFilterAttribute, the post method will create an inner BotAuthentication attribute and delegate OnActionExecutingAsync to it.

willportnoy avatar Aug 04 '16 03:08 willportnoy

I'm going to close this issue, but feel free to open a new issue for further discussions.

willportnoy avatar Aug 09 '16 20:08 willportnoy

Method OnActionExecutingAsync removed in 3.5 version. We need urgent suggestion how to use it?

vovanb avatar Jan 27 '17 19:01 vovanb