我正在实施OAuth2Client,当我致电
时var result = OAuthWebSecurity.VerifyAuthentication();
我结果.IsSuccessful等于false。 我已经看到“OAuthWebSecurity.IsAuthenticatedWithOAuth”方法有以下例外:
'Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.IsAuthenticatedWithOAuth' 引发了'System.MissingMethodException'类型的异常“方法没有 发现:'无效 DotNetOpenAuth.AspNet.OpenAuthSecurityManager..ctor(System.Web.HttpContextBase)”“。 “ 在 Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.GetIsAuthenticatedWithOAuthCore(HttpContextBase 上下文)\ r \ n at Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.get_IsAuthenticatedWithOAuth()“
为什么?
答案 0 :(得分:2)
看起来是因为this change。我opened an issue跟踪并解决此问题。
目前,如果您安装4.0.4.12182版本的DotNetOpenAuth.AspNet,它应该可以解决问题(这是在引入回归之前)。
答案 1 :(得分:1)
我将采用一种解决方法...在我的方案中,我只有一个OAuth客户端,所以如果我将它投射到我的客户端,我可以验证身份验证。
var result = ((MyOAuth2Client)OAuthWebSecurity.GetOAuthClientData("my")
.AuthenticationClient).VerifyAuthentication(HttpContext, Request.Url);