DotNetOpenAuth and WCF WebAPI Integration

I am trying to create a RESTful web service based on the WCF Web API . I also need to control access using OAuth, and for this I use the open source library DotNetOpenAuth.

Has anyone ever succeeded in integrating the two? I'm struggling to convert from representations of HTTP WCF Web APIs to something DNOA understandable (like HTTP requests, HTTP headers, etc.).

Any advice is appreciated.

+4
source share
1 answer

Could you be more specific?

In WebAPI, a request is represented by the HttpRequestMessage . The response is represented by the HttpResponseMessage class.

I already did not know about DNOA, but from what I saw, you can easily create HttpRequestInfo from HttpRequestMessage using the public HttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream) .

The HTTP method and uri request are directly HttpRequestMessage properties. The input stream is obtained through the Content property. I do not see a direct way to create a WebHeaderCollection from the WebAPI HttpRequestHeaders . However, you can WebHeaderCollection over the HttpRequestHeaders records and then insert them into the WebHeaderCollection in turn.

+2
source

All Articles