Making Your Website More Social with Google+ Sign-In
Google+ launched publicly in June 2011, and as of December 2012, it has a total of 500 million registered users. Approximately 235 million are active monthly users. Google+, in addition to being a social networking site, acts as a unifying identity service for many Google properties including YouTube and Google Play.
Google+ Sign-In provides an easy way for users to use their Google+ account as a single point of integration across many websites, versus creating a bunch of accounts with unique passwords they have to remember.
In this article, you learn how to use Google+ Sign-In to manage identity, share, and consume data with Google+ on a third-party website.
Let’s imagine that you are the proprietor of a car dealership and you want to get input on what cars you should offer for sale. You decide that everyday you will feature a new car model that you might want to sell. Visitors to your site can specify if they like the car. You’ve heard a little about Google+ and know that you can allow your visitors to interact with your site without needing to create a new account. You also want them to be able to share actions they do on your site with the outside world. Let’s begin.
Creating a Google API Project
The first step for almost anything that touches Google APIs is a trip to the Google APIs Console. The upside from doing it so often is that eventually muscle memory will kick in and you’ll be creating new projects in your sleep.
Create a new project and make sure Google+ API is turned on under the Services tab. Next, we need to generate the OAuth client ID our application with use (see Figure 1).
The OAuth 2.0 client ID flow will ask you to provide some information about your application, including the name, icon locations, what type of app it is, etc. The only required bits are an application name and application type, as shown in Figures 2 and 3.
The code for the sample app runs on 0.0.0.0:5050, so I’ve added that in the API console as a possible JavaScript origin, as shown in Figure 4.