Working With Yahoo External Provider in MVC 5

Introduction

I described earlier how to do External Authentication in MVC like Google, Facebook and Twitter. So here I am describing to connect with Yahoo. You can use Yahoo as an External Authentication Provider to login with the MVC application.

Here in this article, I am developing the ASP.NET Web Application using the latest MVC 5 in the Visual Studio 2013. So, let's proceed with the following sections:

  • Creating Yahoo App
  • Adding NuGet Package
  • Working with MVC Application

Creating Yahoo App

Use the following procedure create the Yahoo app.

Step 1: Open the developers.yahoo.com

Step 2: Login and on the top right hover on your name to select My Projects.

Creting Projects in UI

Step 2: Now accept the terms and conditions by Yahoo.

Accepting Yahoo Terms

Step 3: It might be possible that you didn't have a single project. If a project exists then you can use that one otherwise click on Create New Project.

Creating New Project on Yahoo

Step 4: Enter the details of the app.

Yahoo App Description

Step 5: Check the check box to accept the terms and conditions and click on Create Project

Creating Yahoo App

Step 6: Now copy the App ID and App Secret of the Yahoo app.

Authentication Information of Yahoo Project

Adding NuGet Package

In this section we'll add the NuGet Package for the MVC application. Proceed with the procedure below.

Step 1: Create the MVC Application

Creating Mvc Project Template

Step 2: Manage NuGet Packages of the application.

MAnaging NuGet Packages

Step 3: Add the OWIN.security.providers package.

Owin Security Providers

Working with MVC Application

In this section we'll add the code to the Authentication file that is used to authenticate the Yahoo app provider in the MVC application. So you just update the App_Start\Startup.Auth.cs file with the following code.

Add the following namspace:

using Owin.Security.Providers.Yahoo;

Add the following code to the class:

app.UseYahooAuthentication("Your App ID""App Secret");

That's it. Now when you run the application login into the application with Yahoo.

MVC Login with Yahoo

Summary

This article described how to login into an ASP.NET MVC application with the External Authentication providers like Yahoo. There are many other providers also available. Thanks for reading.

Up Next
    Ebook Download
    View all
    Learn
    View all