How to use Google plus Signin in Asp.net with Google Plus API



Google plus and Facebook are two Giants of Social networks, Facebook Twitters already have their sign in option for websites, previously Google allow us to sign in with Google accounts which is quite similar, but Now you can sign in with your Google plus account, its indirect sign in to your Google account, By Google Plus Sign in you can access the user information like Profile, circles posts by users and other Google plus Features on your website.

To create your first Sample Google Plus Sign in website you need to create application for your Project.

Step 1

Visit this url

https://code.google.com/apis/console

Create new Project

google plus sign in in asp.net

Step 2

Give the appropriate name for your Project.

google plus sign in in asp.net

Step 3

Add the Homepage URL of your website on which you are going to use this Sign in feature,  add the Product name which Users will see when they sign into your website with Google Plus, Logo is optional for branding.

google plus sign in in asp.net

Step 4

Now Your application has been created now you have to create Oauth Client ID, Click on the button as you can see in the below Image.

google plus sign in in asp.net

Step 5

Select the Type of your application, I am creating a web application so I am choosing web application.

google plus sign in in asp.net

Step 6

Now Copy the Product name, CLIENT ID, CLIENT SECRET you need them to run the sign in process under your created project.

google plus sign in in asp.net

Step 7

I am using the same sample application which is given by Google, You can Download the Sample Application from Here.

This sample application has all the required DLL files for the project so you don’t need to add any additional API DLL for your project.

In signin.ashx.cs file find the following code and add your CLIENT ID, CLIENT SECRET and APPLICATION NAME

// These come from the APIs console:
// https://code.google.com/apis/console
static public string CLIENT_ID = “Your Cliend ID“;
static public string CLIENT_SECRET = “Your Client Secret“;

// Configuration that you probably don’t need to change.
static public string APP_NAME = “Your Project Name“;

// Used internally by the OAuth client
private IAuthorizationState _authState;

// Used to peform API calls against Google+.
private PlusService ps = null;

Again in Index.HTML change the CLIENT ID with Your Client ID

data-scope=”https://www.googleapis.com/auth/plus.login”
data-requestvisibleactions=”http://schemas.google.com/AddActivity”
data-clientId=”Your CLIENT ID here
data-accesstype=”offline”
data-callback=”onSignInCallback”
data-theme=”dark”
data-cookiepolicy=”single_host_origin”>

Now You can run the Project by pressing F5 from your Visual Studio, it will run the Index.html file, there you will see the sign in with Google plus button click the button, and you will see the popup for the Google plus authentication, then you can sign in to your website with the Google Plus, in return this sample application will give you the Profile Picture, profile information, Name and other Details you can check the Documentation from Google for more Information regarding the Google plus with Asp.net.

This is the very new feature, subscribe to get more alerts on Google plus with Asp.net.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>