我使用的是asp.net MVC 4.0和建築OAuth主機使用DotNetOpenAuth庫。 我試圖實現授權方法OAuthController:AuthorizationServer.ReadAuthorizationRequest返回null
[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
!
我知道肯定的方法IClientDescription GetClient(string clientIdentifier)
在OAuth2AuthorizationServer
應該在ReadAuthorizationRequest
調用 - 但實際上它不會調用我的情況。
有沒有人猜測爲什麼會這樣?