This project is read-only.

Integrating DotNetOpenAuth and WCF WebAPI

Topics: Web Api
Aug 5, 2011 at 8:19 AM
Edited Aug 5, 2011 at 8:21 AM

(this is a crosspost from Stackoverflow - - where somebody suggested to try the same question here)

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.


Aug 7, 2011 at 11:13 PM

Could you be a little more specific?

In Web API a request is represented by the HttpRequestMessage class (

A response is represented by the HttpResponseMessage class (

I've no previous knowledge of DNOA, but from what I saw, you can easily create a HttpRequestInfo from a HttpRequestMessage using the public HttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream)

  • The HTTP method and request uri are directly HttpRequestMessage properties.
  • The input stream is obtained via the Content property.
  • I don't see a direct way of creating a WebHeaderCollection from the Web API's HttpRequestHeaders. However, you can iterate the HttpRequestHeaders entries and insert then on the WebHeaderCollection one by one.



Aug 8, 2011 at 8:10 AM


I eventually followed the very same path that you mentioned, so your comment reinforces my intuition.

Thank you,