There are Various Types of Authentication which we can use to login in our Asp.net Applications...This Article Provides a brief Explanation on Twitter Authentication in Asp.net MVC5 Application
Introduction
In this Article we will learn how to Authenticate MVC Application with Twitter Credentials...you can check my Previous article on Facebook Authentication here...
Let's start to authenticate the MVC Application with Twitter :
- Step 1 Register yourself as a App Developer in Twitter by opening https://dev.twitter.com/apps from your Browser and sign in with your Credentials...
Note:- Your Email must be confirmed with twitter before you sign in
- Step 2 Now Click on Create a new Application as shown Below...
- Step 3 Enter all the Necessary Details you can provide a call back URl as www.dummy.com and click on Create your Twitter Application
- Step 4 Copy the consumer key and consumer Secret Values as shown below
Now lets Create a MVC Application
- Step 1 Create an Asp.net MVC Application
- Step 2 After Creation you will find Startup.Auth.cs class file in App_Start Folder
Using the code
- Step 3 Open Startup.Auth class file Here you can watch UseTwitterAuthentication code is Commented..
- Step 4 uncomment the Code and Provide the Consumer key and consumer Secret key which we had copied Earlier
using Owin;
namespace MVCStudents
{
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseSignInCookies();
// Uncomment the following lines to enable logging in with third party login providers
//app.UseMicrosoftAccountAuthentication(
// clientId: "",
// clientSecret: "");
app.UseTwitterAuthentication(
consumerKey: "",
consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
//app.UseGoogleAuthentication();
}
}
}
- Step 5 Debug the Application and click on Login we will find the Twitter Button as shown below

- Step 6 Click on the Twitter Button and you will be ask to Authorize app ..Click on Authorize app