4

I am trying to implement OAuth in a web service such as:

http://www.codeproject.com/Tips/372422/Secure-WCF-RESTful-service-using-OAUTH

Each time, when the Authenticate method is fire, WebOperationContext.Current.IncomingRequest exists, but UriTemplateMatch is null. This is even the case when using the WCF Test Client, so my client app isn't the problem. Ultimately, I need to access the QueryParameters under UriTemplateMatch.

In the Authenticate method, this is where the code breaks:

NameValueCollection pa = context.UriTemplateMatch.QueryParameters;

Looking for a different solution than this so everything is processed in one request:

https://stackoverflow.com/questions/7344478/using-the-wcf-http-web-api-uritemplatematch-is-always-null

Also, just as much as a solution, I am looking for a reason why the UriTemplateMatch would be null only in the case of a WCF Service. There are hundreds of articles on the presence of this problem, but I haven't found a good solution and/or explanation. I think I may be missing something in my web.config.

Community
  • 1
  • 1
elusive
  • 460
  • 5
  • 24

1 Answers1

0

It seems that this solution is expecting incoming calls like :

http://localhost:49262/TestProject/Service.svc/user/123?oauth_consumer_key=key&oauth_nonce=10a33ed37b549301644b23b93fc1f1c5&oauth_signature=cUobFDxVB5wjPe9X2XICJ6awmnE%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1289976718&oauth_version=1.0

There are two ways to attach oauth parameters, one is through headers, another is through query string, both are valid, so I choose to attach oauth parameters in query string. There is not any problem to retrieve them from IncomingWebRequestContext.Headers if those oauth parameters are in headers

This solution is not from me. Check this link.

Bastien Vandamme
  • 17,659
  • 30
  • 118
  • 200