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:
- Googling for other scenarios like mine. Fails because no relevant search results are found (i.e., I am unable to find results that match my scenario)
- Searching for earlier versions of the Microsoft WebPages OAuth library 2.0.20710.0 package. Fails because my search returns no such packages.
- Using
OAuthWebSecurity.RegisterOpenIDClient(BuiltInOpenIDClient.Google);
instead ofOAuthWebSecurity.RegisterGoogleClient();
Fails for the same reason as when usingOAuthWebSecurity.RegisterGoogleClient();
- Visiting Site Administration and downloading the OAuth Library. Fails because NuGet needs an update
- Update Nuget Fails because of what is mentioned here (apparently, a known bug for WebMatrix): http://forums.asp.net/t/1836913.aspx/1?Error+updating+DotNetOpenAuth+updates+with+NuGet+Gallery
- Opening up the Starter Site Template, which already has OAuth built in and functional.Fails to teach me as to why this site recognizes
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. - Creating a new Starter Site and copying any OAuth based missing files from the *"App_Data"* and "bin" folders. Fails in that no behavioral changes were observed.
-----------------------------------------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.