How to implement social login in asp.net mvc 4?

I want to implement role-based login using oauth with facebook, twitter, google etc. It will use only oauth and will have a role system. Not a default template with normal registration and login. It looks like the net open auth dot will help get started, but I can't find a good example of a use or extension. Can someone explain how to use dotnet open auth from scratch and how to get more information?

+5
source share
2 answers
  • Launch Visual Studio 2012
  • Create a New ASP.NET MVC 4 Application Using the Internet Template
  • Open file ~/App_Start/AuthConfig.cs
  • , ,

OAuth DotNetOpenAuth, documentation, .

+10

~/App_Start/AuthConfig.cs this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Web.WebPages.OAuth;

namespace MVCTemplateProject
{
    public static class AuthConfig
    {
        public static void RegisterAuth()
        {

            OAuthWebSecurity.RegisterMicrosoftClient(
               clientId: "code",
                clientSecret: "code");

            //OAuthWebSecurity.RegisterTwitterClient(
            //    consumerKey: "",
            //    consumerSecret: "");

            //OAuthWebSecurity.RegisterFacebookClient(
            //    appId: "",
            //    appSecret: "");
            OAuthWebSecurity.RegisterLinkedInClient("code", "code");
            OAuthWebSecurity.RegisterGoogleClient();
        }
    }
}
0

All Articles