OAuth is another authentication option for websites that use the Simple Membership Provider. A user can be validated using an external account like Facebook, Twitter, Google, and others. The following steps enable authentication using a Google account in the application.
Go to the class
AuthConfig.cs in the
As we are using google, find the RegisterAuth method and uncomment the last line where it calls OauthWebSecurity.RegisterGoogleClient.
Run the application. Once the application is running, click Log in to open the log in page. Then, click Google under Use another service to log in.
This redirects to the Google login page (at google.com), and requests you to sign in with your Google account information.
After submitting the correct credentials, a message requests permission for your application to access the user's information. Read the description and then click Accept to allow the quoted actions, and to redirect back to your application's login page.
Now your application can register the account. The User name field will be filled in with the appropriate information (in this case, the email address that is associated with the Google account). Click Register to register the user with your application.
Now the new user is logged into the application from an external source using OAuth.
Information about the new user is stored in the
To use another external option to authenticate users, you must enable the client in the same class where we enabled the Google provider in this tutorial. Typically, providers require you to register your application before allowing OAuth authentication, and once registered they typically provide a token/key and an ID that must be used when registering the provider in the application.