O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Third-party authentication of users using Google

Before Version 4.5, ASP.NET Web Pages used to provide functionality to authenticate users using third parties such as Google, Live, Facebook, Twitter, or similar third parties, through installable helpers. These helpers were categorized as Open Authentication (OAuth) helpers. However, with Version 4.5, OAuth helpers have become part of the standard ASP.NET Web Pages library. In this recipe, we will see how to use OAuth helpers to enable Google authentication in a website.

How to do it...

  1. Create a new Web Site project. Name it GoogleAuthentication.
  2. Open _AppStart.cshtml. Add the following code after the call to WebSecurity.InitializeDatabaseConnection:
    OAuthWebSecurity.RegisterOpenIDClient(BuiltInOpenIDClient.Google); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required