我正在使用 asp.net MVC 4.0 并使用DotNetOpenAuth库构建OAuth主机。我正在尝试在OAuthController中实现Authorize方法:
[Authorize, AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult Authorise()
{
using (OAuth2AuthorizationServer server = (new OAuth2AuthorizationServer(new X509Certificate2(ConfigurationManager.AppSettings["AbsolutePathToPfx"], ConfigurationManager.AppSettings["CertificatePassword"]), new X509Certificate2(ConfigurationManager.AppSettings["AbsolutePathToCertificate"]))))
{
AuthorizationServer authorizationServer = new AuthorizationServer(server);
EndUserAuthorizationRequest pendingRequest = authorizationServer.ReadAuthorizationRequest();
if (pendingRequest == null)
{
throw new HttpException((int) HttpStatusCode.BadRequest, "Missing authorization request.");
}
//**
}
}
我得到了pendingRequest == null
!
我确定应该调用 inIClientDescription GetClient(string clientIdentifier)
方法- 但实际上在我的情况下它不会调用。OAuth2AuthorizationServer
ReadAuthorizationRequest
有没有人有任何猜测为什么会这样?