BotAuth与Azure表存储错误

我正在使用BotAuth nuget包登录我的机器人用户。最近,我按照https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage中提到的步骤执行Azure Table存储以存储和管理机器人状态数据。BotAuth与Azure表存储错误

我的Global.asax.cs文件看起来像这样:

public class WebApiApplication : System.Web.HttpApplication 

{

protected void Application_Start()

{

var store = new TableBotDataStore(CloudStorageAccount.DevelopmentStorageAccount);

Conversation.UpdateContainer(builder =>

{

builder.Register(c => store)

.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)

.AsSelf()

.SingleInstance();

builder.Register(c => new CachingBotDataStore(store,

CachingBotDataStoreConsistencyPolicy

.ETagBasedConsistency))

.As<IBotDataStore<BotData>>()

.AsSelf()

.InstancePerLifetimeScope();

});

GlobalConfiguration.Configure(WebApiConfig.Register);

}

}

而且MessagesController是一样的人在BOT模板:现在

[BotAuthentication] 

public class MessagesController : ApiController

{

/// <summary>

/// POST: api/Messages

/// Receive a message from a user and reply to it

/// </summary>

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)

{

if (activity.Type == ActivityTypes.Message)

{

await Conversation.SendAsync(activity,() => new Dialogs.RootDialog());

}

else

{

HandleSystemMessage(activity);

}

var response = Request.CreateResponse(HttpStatusCode.OK);

return response;

}

private Activity HandleSystemMessage(Activity message)

{ ...... }

}

,在测试它,我得到如预期的登录卡和点击并完成授权过程后,我在浏览器中出现以下错误:

{ 

"message": "An error has occurred.",

"exceptionMessage": "Object reference not set to an instance of an object.",

"exceptionType": "System.NullReferenceException",

"stackTrace": " at BotAuth.AADv1.ADALAuthProvider.<GetTokenByAuthCodeAsync>d__4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at BotAuth.Controllers.CallbackController.<Callback>d__3.MoveNext()"

}

我错过了什么?它是一些autofac模块注册。有没有人有任何工作示例。

回答:

正如@FeiHan在评论中指出的那样,这是richdizz/BotAuth中的一个公开问题。 - "Enabling custom state service causes authentication failure"

此问题已得到修复MicrosoftDX/botauth,因此最好使用这一个,而不是

以上是 BotAuth与Azure表存储错误 的全部内容, 来源链接: utcz.com/qa/266913.html

回到顶部