The Google API App
In order to utilize the Google API, you will need to create a Google app. These instructions will walk you through how to setup your app via the Google Developer Console.
1. Login to Google Developer Console
Visit Google Developer Console and login with your Google account.
2. Create a New Project
Click on CREATE PROJECT and enter a name for your project. Then, click Create.
You should, then, be redirected to a list of your projects.
Look for a notification containing a link on the words SELECT PROJECT. Click them to change to the project that you just created.
You should now see a dash board, of your new project, containing lots of information. Look for a menu on the left and locate APIs & Services.
3. Configure OAuth Consent Screen
Hover your mouse over the menu till you see APIs & Services > OAuth consent screen then click it. You will be taken to the OAuth consent screen.
On the OAuth consent screen select External and click Create.
The next screen is where you will enter details about your google app. Fill in the required fields, marked with a red asterisk *, under App Information and Developer Contact Information. Then, click Save and Continue.
Next, we setup the necessary Scopes. Look for a button labeled ADD OR REMOVE SCOPES. Click it. You will see a popup screen with a list of available scopes, basically services, that you can give your app permission to utilize. We will look at how to make more services available in your list of scopes at a later time. For now, we will use what is already available and that is the /auth/userinfo.email, /auth/userinfo.profile, and openid. You can search for each one, and click the check box to select it. When you are finished selecting all three, click the UPDATE button. This will return you back to the main Scopes screen. Click the button labeled SAVE AND CONTINUE.
Next is the Test Users screen. You can add any external users that you wish to be able to use your app for now. This screen is optional, you can skip it if you like. Click the button labeled SAVE AND CONTINUE.
You should be on the Summary screen. You don't have to do anything here except review the details of your app. You can click the button labeled BACK TO DASHBOARD.
4. Create OAuth 2 Credentials
In the menu, to the left, click on Credentials. You will be taken to the Credentials screen.
Near the top of the screen, locate the CREATE CREDENTIALS button and click it. A list will drop down with a few options. Click the one labeled OAuth client ID.
You will be taken to a new screen with another drop down list of options labeled Application Type. Expand the Application Type list and then click on Web application.
For now, just fill in the Name and click ADD URI below Authorized redirect URIs. You will need to enter a fully qualified url, along with the name of the page where you will want the user to redirect to. For our purposes, the name of the page is login.php. Enter in your url, where you will be setting up and testing the script. Something like: https://localhost/login.php. At the bottom of the screen, click the button labeled CREATE.
You will be redirected back to the Credentials screen with a popup titled OAuth client created showing your Client ID and your Client Secret. We will need those values later for when we setup the login with google script.
Congratulations!
Congratulations! You have successfully set up your Google API project. Follow the next tutorial to learn how to a. Login using the Google API and PHP
Reach out to me if you have any questions or feel anything isn't clear in this guide.