ASP.NET Identity 2.0 simplifies task of social authentication in an ASP.NET MVC App at the great extent. There are lot to learn about ASP.NET Identity 2.0 and in further posts I will cover that. However In mean time if you are curious you can find the resources for ASP.NET Identity 2.0 here

To start with I created an ASP.NET MVC Application in Visual Studio 2013 y choosing MVC project template as follows:

clip_image002

Great, once the project is created next you need to configure Twitter for the application. To start with navigate to https://apps.twitter.com and select Create New App as shown below:

clip_image004

To create the Twitter application fill the form as follows. Off course you should provide Name, Description and Website information as of your application. Callback URL filed is worth discussing here, for development environment use 127.0.0.1 instead of localhost as the server for Callback URL. For any other server give fully qualified server name. To create the new Twitter application form can be filled as follows:

clip_image006

That’s it. Now click on API Keys and copy the API Key and API Secret, you will need them in the application.

 clip_image008

At the last step you need to open the project and browse to the App_Start folder. In this folder you will find a file Startup.Auth.cs. Open this file and uncomment the code app.UseTwitterAuthentication. You should also provide the consumerKey and consumerSecret key from Twitter here. (we created these keys in previous steps)

Startup.Auth.cs

clip_image010

This is it Press F5 to run the application. And click on Login, you should see the Twitter option in Use another Service to log in.

clip_image012

Click on the Twitter option and you will be asked to authorize the app.

clip_image014

Once authorization is done, you can register with the Twitter username.

clip_image016

Now you are logged in to the application using Twitter account. So as you see ASP.NET Identity 2.0 makes it super easy to work with social authentication in the ASP.NET MVC or the ASP.NET application.

In further posts, I will share more on ASP.NET Identity 2.0 learning. Happy Coding.

Advertisements

2 thoughts on “Walkthrough: Login with Twitter Account in ASP.NET MVC 5 APP using ASP.NET Identity 2.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s