Open waynehsmith opened 7 years ago
Same issue. Did you figure out how to get past this problem?
If someone has the answer to this please post.
Thanks!
Afraid not.. I'm still experiencing the problem.
@weretygr @yellowwidget @shrubby
This is due to the fact that the current implementation of AuthBot is using the default state client in the OAuthCallbackController. Modifying the controller as follows will make it work with the TableBotDataStore implementation you are using:
1) add a new class that implements IAddress:
public class AddressKey : IAddress
{
public string BotId { get; set; }
public string ChannelId { get; set; }
public string ConversationId { get; set; }
public string ServiceUrl { get; set; }
public string UserId { get; set; }
}
2) In place of IStateClient sc = scope.Resolve
var botDataStore = scope.Resolve<IBotDataStore<BotData>>();`
3) Instead of sc.BotState.GetUserData use the botDataStore to retrieve the user BotData object:
var userData = await botDataStore.LoadAsync(key, BotStoreType.BotUserData, CancellationToken.None);
4) Instead of sc.BotState.SetUserData use the botDataStore to save the userData
await botDataStore.SaveAsync(key, BotStoreType.BotUserData, userData, CancellationToken.None);
await botDataStore.FlushAsync(key, CancellationToken.None);
I've created a PR for this: https://github.com/MicrosoftDX/AuthBot/pull/37
@EricDahlvang - Thank you very much for your time investigating and figuring this out. I just tested and it works great.
How do we fix this as we are using the AuthBot Nuget
@vibjain Please switch your project to using BotAuth. AuthBot uses the default state client, and will be deprecated in the future.
https://www.nuget.org/packages/BotAuth/3.9.0-alpha https://github.com/richdizz/BotAuth
Can you provide some guidance on moving to the BotAuth, currently I am stuggling with the ContextExtensions methods like Logout & GetAccessToken will we have to implements these methods ourselves now? I don't see them in the BothAuth anywhere. Thanks
There is a little information on this page: https://github.com/richdizz/BotAuth/tree/7138ecf743423bcf13f53c09644ecdb60f0ec7da/CSharp and five sample applications. Have you reviewed those?
Hi @EricDahlvang, thanks for your help. I think I made progress and changed my code form AuthBot to BotAuth. However after completing all the steps I am hitting this open issue. https://github.com/richdizz/BotAuth/issues/8 So, I cannot use the TableBotDataStore because AuthBot is not compatible & BotAuth has an open issue currently.
@vibjain I've created a PR to address this: https://github.com/richdizz/BotAuth/pull/10 Until it is merged, you can clone the repository, modify the local CallbackController.cs and include it in your project.
I hope this helps.
Install Azure Storage Emulator and check operation
Steps to reproduce using SampleAADv2Bot:
in Global.asax.cs
Add the following after the Application Start method private void ConfigureBotTableStorage() { string tableName = "UserStateDev";
Before the line
GlobalConfiguration.Configure(WebApiConfig.Register);
insert the lineConfigureBotTableStorage();
Save and compile
Connect to the bot on http://localhost:3978/api/messages with the Bot Framework Channel Emulator
Send logon to the bot inthe emulator
Click the Authentication Required link in the emulator
Log in using a Microsoft account in the browser window that opens
Copy the magic number to send back to the bot
Expected behavior
Bot prompts for the magic number
Actual behavior
Bot displays sign-in card again.