CODING ACADEMY

View Original

HOW TO CREATE A WEBSITE LOGIN USING THE GOOGLE API

NEWLY UPDATED COURSE

In this course, you will learn how to create a website login using the Google API. The course covers everything you need to get a website login up and running in under 1 hour.

The course starts by creating a server on the Codeanywhere development environment. Using Codeanywhere in the course ensures that you can receive full support. However, you are welcome to use any development environment you wish.

Once the server has been created, the next step is to create the Google login button. Using Emmet and some basic HTML and Bootstrap styling you will end up with a simple login button that looks something like this:

The next step in the course is to install the Google API PHP client files on the server. This is done using Composer.

Next, the configuration files are created before heading over to the Google Developer Console to create a project and download the API credentials.

WHAT IS THE PROCSS OF LOGGING IN USING THE GOOGLE API?

The process of logging in involves creating an authorised URL which you will attach to the login button. Once the button is clicked you will be taken through to the Google authentication page where you will give permission for your app.

An authorisation code is then sent to a callback script which processes this and exchanges it for a login token. The token is stored in a session and is used to confirm login status and hence provide access to any secure pages on your website.

WHAT DOES THE GOOGLE LOGIN COURSE COVER?

The course includes the following:

  • create a server on Codeanywhere

  • design a login button using Bootstrap

  • install the Google PHP API library using Composer

  • use the Google Developer Console

  • retrieve a unique AuthURL from Google

  • implement login scripts

  • create a secure page

  • retrieve user data from Google

  • present user data in a styled table using Bootstrap

  • create a log out script

  • revoke a Google user token

Each line of code is explained so that you will be able to understand the processes involved. The status of the session cookie and token are shown as you log in and log out. The token is manually revoked through your Google Admin panel and also via code so that you can see how this affects access to your website.