I am trying to create a RESTful web service based on WCF Web API. I also need to control access using OAuth and for this I am using the DotNetOpenAuth open source library.
Has anyone ever been successful integrating the two? I am struggling converting from the HTTP entities representations of the WCF Web API into something that’s understandable by DNOA (e.g. HTTP requests, HTTP headers, etc…).
Any tip would be greatly appreciated.
Could you be a little more specific?
In WebAPI a request is represented by the
HttpRequestMessageclass. A response is represented by theHttpResponseMessageclass.I’ve no previous knowledge of DNOA, but from what I saw, you can easily create a
HttpRequestInfofrom anHttpRequestMessageusing the publicHttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream).The HTTP method and request uri are directly
HttpRequestMessageproperties.The input stream is obtained via the
Contentproperty. I don’t see a direct way of creating aWebHeaderCollectionfrom the WebAPI’sHttpRequestHeaders. However, you can iterate theHttpRequestHeadersentries and insert then on theWebHeaderCollectionone by one.