Monday, 30 November 2015

ASP.Net Identity 2 Authentication Via Google Setup - Step 27

> C#/.Net Samples
> .Net Authentication
> Setting up ASP.NET Identity 2 with External Logins Facebok Google Microsoft and Twitter

Step # 27

 

For other steps follow:

Setting up ASP.NET Identity 2 with External Logins Facebook Google Microsoft and Twitter



Go to https://console.developers.google.com/ and setup id and secret
 
·         Click the Create Project button and enter a project name and ID (you can use the default values). In a few seconds the new project will be created and your browser will display the new projects page.
·         In the left tab, click APIs & auth, and then >  Credentials.
·         Click the Create New Client ID under OAuth.
·         In the Create Client ID dialog, keep the default Web application for the application type.
·         Set the Authorized JavaScript origins to the SSL URL you used above (https://localhost:44300/ unless you've created other SSL projects)
·         Set the Authorized redirect URI to https://localhost:44300/signin-google

Enable google authentication in Startup.Auth.cs



app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
             
app.UseGoogleAuthentication(
                clientId: "*****************",
                clientSecret: "****************");
 
 
Place a new button for google in login view



<!-- The best practice here is to follow the sample applications approach -->
@using (Html.BeginForm("GoogleLogin", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    <p>
        <button class="btn btn-primary" type="submit">Login via Google</button>
    </p>
}




Social Media Links

External Login Basics
Google Setup
Facebook Setup
Twitter Setup
Microsoft Setup
External Login Controller Actions