If I misuse or confuse the terms OpenID and OAuth, I apologize, I am still new to this whole decentralized login process.
I have been trying for days now to get my site (built in WebMatrix) to recognize a Google login. The problem is I need this line of code (from what I've researched) in my _AppStart.cshtml
file:
OAuthWebSecurity.RegisterGoogleClient();
But when I try to run this site after this statement is in place, I simply get a server error stating that OAuthWebSecurity.RegisterGoogleClient();
does not exist in the current context.
I thought I might need the OAuth library, a different helper, or some other package, but the only relevant package I see (Microsoft WebPages OAuth library 2.0.20710.0) I can't get, because WebMatrix doesn't support the version of NuGet it says that I need (2.0).
I have never used this method for a log in before and I want to learn how as I build this functionality for my clients. What I do not want to do is open up the starter template, and copy my files over. I have a problem using code that I don't understand. I feel that this would be a terrible habit for me to get into (it took some convincing myself before I would even use jQuery plug-ins). It also might bear mentioning that I will not be using any other third party service for this login. We use gmail for our employees' company email accounts so I need only Google logins for this solution.
Things I have tried:
OAuthWebSecurity.RegisterOpenIDClient(BuiltInOpenIDClient.Google);
instead of OAuthWebSecurity.RegisterGoogleClient();
Fails for the same reason as when using OAuthWebSecurity.RegisterGoogleClient();
OAuthWebSecurity.RegisterGoogleClient()
and mine doesn't, because there is no clear way (that I am aware of) to tell what pacakages, updates, and/or versions of third party software might be different.
-----------------------------------------UPDATE----------------------------------------
So far, to date, the best solution for this problem, at least for me, has been to just use the "Starter Site" template in WebMatrix, whether I like it or not.
One of my biggest worries for doing this, however, was that there were so many extraneous files that I wasn't sure what I could and couldn't delete to keep the site clean while still leaving the OAuthWebSecurity()
class fully accessible and functional. I have, however kept only the "bin" and "App_Data" folders (including all of their contents, of course) from the "Starter Site" template and deleted everything else (including the web.config file) before moving my files over, and this has appeared to work very well for me, so far.
Using the above mentioned steps, I have kept my site clean of unnecessary code, while still having access to the OAuthWebSecurity()
class.
In the future (I imagine when WebMatrix 3 is released) this bug will probably be fixed and a simple admin site install of the OAuth library will not require a version of NuGet that WebMatrix does not support, but until then, this has been the best answer for me.
Does this GitHub project help : WorldDomination.Web.Authentication ??
there's also an MVC and NancyFX nuget package which does some auto wiring up, if that takes your fancy.
DISCLAIMER: I've never tried this in Webmatrix
and will never plan on trying it, in that. That said, it might still work! :)
Have you tried following package?
PM> Install-Package Microsoft.AspNet.WebPages.OAuth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With