简体   繁体   中英

Integrating DotNetOpenAuth and WCF WebAPI

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 (eg 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 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 an 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 WebAPI's HttpRequestHeaders . However, you can iterate the HttpRequestHeaders entries and insert then on the WebHeaderCollection one by one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM