OpenId support

Dec 24, 2009 at 2:16 PM

Over the past few days, I've been trying to use OpenId / OAuth with C# WebServer using DotNetOpenAuth. Unfortunately, the DotNetOpenAuth project seems closely tied to ASP.NET and ASP.NET MVC. It's been tricky to unwrap all the helper classes to figure out what actually needs to be sent over the wire.

Then I noticed that jhurliman (who contributes to this C# WebServer project) had run into similar issues with DotNetOpenAuth a few months ago!

Were you able to get it working, John? Could you contribute the code back to the C# WebServer project? It would make a great addition to the  existing Authentication Modules.

Dean

Jan 4, 2010 at 7:46 PM

DThrasher,

DotNetOpenAuth includes non-ASP.NET samples for both OpenID and OAuth apps.  What trouble are you running into?

(better yet, email dotnetopenid@googlegroups.com or send a Google Wave the same address for faster help)

Jan 4, 2010 at 9:02 PM

Thanks, Andrew. I'll start poking around in the Google group threads at http://groups.google.com/group/dotnetopenid/

I found an answer to my original issue, which had to do with the lack of an HttpContext object in C# WebServer. The OpenIdRelyingParty object tries to grab the HttpContext and fails using the default constructor. By passing a null for IRelyingPartyApplicationStore, I could simply put DotNetOpenId in stateless mode instead.

OpenIdRelyingParty openid = new OpenIdRelyingParty(null);

But now I'm getting a "No OpenID endpoint found" error when I call

openid.CreateRequest(Identifier.Parse(loginIdentifier));

I think that usually indicates a proxy error, but I've got some more digging to do.

Jan 4, 2010 at 9:10 PM

From: DThrasher

Thanks, Andrew. I'll start poking around in the Google group threads at http://groups.google.com/group/dotnetopenid/

I found an answer to my original issue, which had to do with the lack of an HttpContext object in C# WebServer. The OpenIdRelyingParty object tries to grab the HttpContext and fails using the default constructor. By passing a null for IRelyingPartyApplicationStore, I could simply put DotNetOpenId in stateless mode instead.

OpenIdRelyingParty openid = new OpenIdRelyingParty(null);

Yup.  That's one solution.  Another is to provide your own state-managing class and pass that in. 

But now I'm getting a "No OpenID endpoint found" error when I call

openid.CreateRequest(Identifier.Parse(loginIdentifier));

I think that usually indicates a proxy error, but I've got some more digging to do.

I agree.  Proxy might be the problem.  There's a .config file setting you can use to get .NET to automatically use the system default proxy that might help here.  But you also need to call the CreateRequest overload that accepts a realm and returnTo parameter, since those parameters can't be auto-detected from your ASP.NET HttpContext either.
Jan 4, 2010 at 11:07 PM

Aha! That was the problem. After supplying the Realm and ReturnTo parameters, it worked just fine.

Out of curiosity, does DotNetOpenAuth have an example for creating a custom IRelyingPartyApplicationStore? Wait, wait... I just found it in the samples!

OpenIdRelyingPartyWebForms/Code/CustomStore.cs

Awesome. Thanks for your help Andrew. I'll keep playing around with it.