Update: 1 April 2015 - The latest and most up to date version of the LinkedIn guide is available on the OAuth for ASP.NET website
Update: 1 April 2015 - The latest and most up to date version of the Yahoo guide is available on the OAuth for ASP.NET website
In my previous blog bost I wrote about the Google+ OAuth provider which I developed for ASP.NET Identity (OWIN). This code has since been taken over by Microsoft and will be integrated into the Katana project. I had some extra time on my hands and set about developing OAuth providers for LinkedIn and Yahoo, as they were apparently the ones which most people requested to be added.
I am glad to announce that these providers are now ready for you to use in your own projects. In this blog post I will explain how to use these two security providers in your own application. If you are not familiar with ASP.NET Identity I suggest you start of by reading the article entitled Create an ASP.NET MVC 5 App with Facebook and Google OAuth2 and OpenID Sign-on on the ASP.NET website.
Installing the package via NuGet
The first step is to install the package via NuGet. The name of the package is Owin.Security.Providers
Registering the Yahoo provider
To use the Yahoo OAuth provider you will need to create a project on the Yahoo Developer Network. First step is to head over to http://developer.yahoo.com/ and register as a developer. Once you are registered as a developer you will need to register a project to obtain a consumer key and secret.
Click on your name in the top right corner and select My Projects:
You will see a list of the existing projects which you have registered (if any). Click on the Create Project button to register a new project.
Complete the new project form. Make sure that under Application Type your select ‘Web-based’. Under Access Scopes select ‘This app requires access to private user data’ and be sure to select at least one of the APIs under ‘Select APIs for private user data access’. If you do not select at least one of the APIs your will get all sort of weird errors coming back from Yahoo, so just go ahead and pick one of the APIs.
Once you are done you can click on the Create Project button. After the project is created you will be presented with a screen which will display your Consumer Key and Consumer Secret
Head on over to the Startup class located in App_Start\Startup.Auth.cs and add the namespace:
Next register the Yahoo provider in the ConfigureAuth method:
app.UseYahooAuthentication("<YOUR CONSUMER KEY>", "<YOUR CONSUMER SECRET>");
Register the LinkedIn provider
To use the LinkedIn provider you will also need to register an application on LinkedIn. Head on over to http://developer.linkedin.com and ensure that you are registered as a developer. Click on your name in the top right corner and select API Keys:
You will be presented with a list of your current registered applications, if any. Click on Add New Application.
Go ahead an complete all the required information. Once done you will be presented with a screen which displays a summary of the new application, including the API Key and Secret Key. Take note of those two as you will need them next when you register the LinkedIn security provider.
Once again head on over to the Startup class located in App_Start\Startup.Auth.cs and add the namespace:
And finally register the LinkedIn provider in the ConfigureAuth method:
app.UseLinkedInAuthentication("<YOUR API KEY>", "<YOUR SECRET KEY>");
This blog post showed you how to easily add external authentication using Yahoo and LinkedIn to your application. The repository for the providers are located at https://github.com/owin-middleware/OwinOAuthProviders, so if you experience any issues or if you want to add more providers please clone the repository and send a pull request.
You can stay updated with my latest blog posts and other interesting tidbits I find on the internet by following me on Twitter at @jerriepelser. Also feel free to reach out to me on Twitter if you have any other feedback on my blog.
If you liked this blog post, please share it on social media:
I am available for remote contract work.
I am available for part-time, remote contract work on ASP.NET projects. If you need are short staffed and need someone to help out, please get in contact by clicking the button below.Find out More