Google APIs Client Library
Refer at github for template (updated at 24 OCT 2023)
The Google API Client Library enables you to work with Google APIs such as Gmail, Drive or YouTube on your serve.
Installation
Composer
You can use Composer or simply Download the Release. Follow the installation instructions if you do not already have composer installed.
Once composer is installed, execute the following command in your project root to install this library:
composer require google/apiclientFinally, be sure to include the autoloader at login_google.php:
require_once 'vendor/autoload.php';\
Google Cloud Console Setup
Open Google Cloud Console, Select the [button] on the left upper corner and create a new project.

Select [APIs and services]

Select [OAuth consent screen], select [External] as User Type, and [Create]

The label which has * is compulsary to fill in, etc [App name], [User support email] and [Email address]. Other is optional and can left empty.

You can leave it blank at this [Scope] page

You can leave it blank at this [Test user] page.

Check the data fill in, if nothing wrong, then [BACK TO DASHBOARRD]

Remember to set the publishing status to publish by clicking [PUBLISH APP]. Noted: If you were not set to publish, then you have to add your test user email account to able use the google API

Select Credentials, then [CREATE CREDENTIALS] >> [OAuth client ID]

Select [Application type] as Web application, fill in the [Name] and [Authorised redirect URLs] of your login page. In my case, i build my login page at http://localhost:3000/login_google.php.

Copy the [client ID] and [Client Secret] here. It will be using later on.

Implementation on Your Website
login_google.php
login_google.phpreplace the $clientID and $clientSecret to your [client ID] and [Client Secret]
button.php
button.phpCreate a login button to header to login.php
PHP
HTML
Last updated