Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/u591492611/domains/codeone.in/public_html/application/third_party/google-login-api/service/apiUtils.php on line 58
CodeOne
CodeOne
PHP Google OAuth Login PHP Google OAuth Login
Sunday, 30 May 2021 23:30 pm
CodeOne

CodeOne

PHP Google OAuth API allows users to login in a website with their Google credentials. A user with a Google account need not remember yet another username/password for a web application. This PHP tutorial is to learn about setting up an authentication system for your custom web application using Google OAuth.

Google OAuth Prerequisites

Create Google API project and get OAuth credentials.
Download / Install PHP Google API client library.

Steps to implement Google authentication

Create / Send authentication request.
Access user data from Google.

Create Google OAuth Credentials

Create a new project and get the corresponding OAuth credentials using Google developer console page.

create_google_project

Select APIS & AUTH –> APIs from Google project dashboard and enable Google+API.

enable_google_api

Select APIS & AUTH –> credentials from the left menu.

get_oauth_credential

Click Create new Client ID button and complete data on this wizard.
create_client_id
After submitting this form, we can get the client Id, secret key and etc as below,

google_oauth_client_id

Click Create New Key to create server key as Google project’s developer key. We should keep this key secure.

Finally, we have to design consent screen that will be shown on requesting user data.

Note: All the credentials we got from this step will be used later in our code for creating client request.