gpt4 book ai didi

asp.net-mvc-4 - OAuthWebSecurity.VerifyAuthentication IsSuccessful 返回 false 如何确定原因?

转载 作者:行者123 更新时间:2023-12-01 18:42:22 26 4
gpt4 key购买 nike

我正在将 DotNetOpenAuth 与 MVC 4 应用程序一起使用。突然,Google 身份验证失败(MS 正在工作)。股票代码的作用是:

[AllowAnonymous]
public ActionResult ExternalLoginCallback(string returnUrl)
{
var result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
if (!result.IsSuccessful)
{
return RedirectToAction("ExternalLoginFailure");
}

我知道result.IsSuccessful是错误的,但我如何得到原因? result.Error 为空。

我还查看了this page使用 log4net。我确实在本地开发盒上获得了日志,但当我将其部署到远程服务器时却没有。

log4net 网络配置:

<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="RelyingParty.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
</root>
<!-- Specify the level for some specific categories -->
<logger name="DotNetOpenAuth">
<level value="ALL" />
</logger>
</log4net>

编辑我还尝试了 log4net 到 sql 数据库,但它仍然没有记录任何内容

最佳答案

我终于明白了这一点。我收到的实际错误消息:

Protocol error: This message has a timestamp of 10/23/2012 12:19:33 PM, 
which is beyond the allowable clock skew for in the future.

事实证明,服务器崩溃后时区设置不正确。这导致谷歌端的验证/ token 失败。

AdoNetAppender“不起作用”,因为 bufferSize 设置为 100。将其设置为 1 后,它开始获取日志。这是我正在使用的 adonetappender

  <log4net>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionStringName value="CONNECTIONSTRINGNAME" />
<commandText value="INSERT INTO Log4Net ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="@log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="@logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="@message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>
</appender>
<root>
<level value="Debug" />
<appender-ref ref="AdoNetAppender" />
</root>
<logger name="DotNetOpenAuth">
<level value="ALL" />
</logger>
</log4net>

解决问题后,您应该将 bufferSize 设置回 100。

关于asp.net-mvc-4 - OAuthWebSecurity.VerifyAuthentication IsSuccessful 返回 false 如何确定原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com