Playing with oAuth on .NET web forms app





Today is a day off for me… but i’m kind of geeking out the last couple of hours.  Got a call a little after 6am and one of the servers i manage was having an issue, so i coaxed it to life so my teammate could get some work done.  no big.  didn’t take long.  back on track for the morning.

saw the wife and kids off to school and work as i from the cup of joe my wife had so lovingly delivered to me just moments earlier, and thought, well since the laptop is already fired up and connected to the vpn… why not tinker just a bit with oAuth.

Why not indeed.  This was magical.  within minutes our little starter app was connected to Facebook and a few minutes later I was logged into the seedling app with my fb creds.  right. on. man.



built the shell of the app using webforms in visual studio.  I like to add in ajaxcontroltoolkit from the nuget package manager

for some reason i can never remember to update the site master and have to refer to this awesome page by Stephen Walther, and verify the app builds successfully.

with the formalities out of the way it’s time to connect to facebook.  in the solution explorer, i browsed to the OpenAuthProviders.ascx file and opened it up, not knowing what i’d see.  Remember, I’m a newbie here and have never. done. this. before.  Right there in the page code is a handy link:



So i followed the link to a very simple document detailing the steps i needed to take.  In this case that amounted to signing up at, creating a new app, and getting an appid and secret key.  After doing that I went back into the Solution Explorer and plugged that info into the appropriate file in App_Start.  Done.  Houston, we have login.

What a great tool.  Props to Facebook for the ease of integration, and props to Microsoft for making it dead simple to add to your solution. I’m sure the same goes for the Twitter and OpenID APIs; I just happened to start with Facebook.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.