1

I'm using asp.net MVC 4.0 and building OAuth host using DotNetOpenAuth library. I'm trying to implement Authorise method in OAuthController :

[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.");
        }
        //**
    }
}

and I'm getting pendingRequest == null!

I know for sure that method IClientDescription GetClient(string clientIdentifier) in OAuth2AuthorizationServer should be called in ReadAuthorizationRequest - but in fact it doesn't call in my case.

Does anybody has any guesses why is it so?

2 Answers 2

0

I've figured out issue. To cut long story short - client wasn't inplemented correctly. Client is responsible for containing such info as :

  • client_id
  • redirect_uri
  • state
  • scope
  • response_type

and not all fields were set up

0

If you are working off of code sample as described here: https://github.com/DotNetOpenAuth/DotNetOpenAuth/wiki/Security-scenarios

Here are some sample values to call the OAuthController Auth() action:

- client_id=RP
- response_type=code
- redirect_uri=https://localhost/RP/Secure4ownAuthSvr/OAuth
- scope=http://localhost/demo
- state=""

Your call would look like this (using Fiddler):

GET
http://localhost/OAuth2/Auth?client_id=RP&response_type=code&redirect_uri=https://localhost/RP/Secure4ownAuthSvr/OAuth&state=&scope=http://localhost/demo

POST
http://localhost/OAuth2/Auth
Content-Type: application/x-www-form-urlencoded; charset=utf-8
client_id=RP&response_type=code&redirect_uri=https://localhost/RP/Secure4ownAuthSvr/OAuth&state=&scope=http://localhost/demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.