MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Add Sign-in with Google feature in Laravel.

In this tutorial, we’re going learn how to add authentication via Google to a Laravel app. In Short, How to add Sign-in with Google feature in our Laravel Project. For that, we use Laravel Socialite Package which is officially provided by Laravel (you can check Documentation here.)

Socialite supports Facebook, Twitter, LinkedIn, Google, GitHub and Bitbucket.

Note :- For using Socialite Package, you must have Laravel 5.4 or an Upper version of Laravel in your project. (Recommended 5.5 and above.)

I’m using Laravel 5.8 (version) in my project. So Follow the below Steps to add Sign-in with Google Functionality in your existing Laravel Project.

Step 1 :- Install Socialite using composer by below Command.

composer require laravel/socialite

Step 2 :- Go to config/services.php and add a new Package as below.

‘google’ => [
‘client_id’ => ‘GOOGLE_CLIENT_ID’,
‘client_secret’ => ‘GOOGLE_CLIENT_SECRET’,
‘redirect’ => ‘http://your-callback-url’,
],

We’ll obtain client_id, client_secret and redirect URL in next Step.

Since we added a new package, make sure to add to the service providers array in config/app.php (In providers array)

‘providers’ => [
// Other service providers…

Laravel\Socialite\SocialiteServiceProvider::class,
],

Add an alias in config/app.php, so it is easier to reference later.

‘Socialite’ => Laravel\Socialite\Facades\Socialite::class,

Step 3 :- Now, Create your app on Google.

( i ) Create a Project :- Go to https://console.developers.google.com/projectcreate and create a new project as shown below.

Google Cloud New Project form with project name test and the Create button

( ii ) Create credentials :- After creating a new project, create credentials.

First, click on Create credentials and then select OAuth client ID. See the below image.

Google APIs Credentials page with Create credentials menu open and OAuth client ID highlighted

After that, Select Web application and fill Name, your_web_URL and redirect_URL and then click on create. See the below image for help.

Redirect URL is like your_web_URL/login/google/callback

Create OAuth client ID form for a web application with localhost:8000 origin and /login/google/callback redirect URI

After Clicking on create a Popup Appears with Your_Client_ID and Your_Client_Secret. See the Below Image.

OAuth client created dialog in Google APIs showing the client ID and client secret

just copy and paste it in the config/services.php as mentioned in Step 2. See the below image.

Laravel config/services.php google entry with client_id, client_secret and callback redirect URL

Step 4 :- Handle the route. Go to routes/web.php. See the below code.

Route::get(‘login/google’, ‘Auth\LoginController@redirectToProvider’);
Route::get(‘login/google/callback’, ‘Auth\LoginController@handleProviderCallback’);

Step 5 :- Now go to loginController and paste the below code.

use Socialite;

public function redirectToProvider()
{
return Socialite::driver(‘google’)->stateless()->redirect();
}


public function handleProviderCallback()
{
$user = Socialite::driver(‘google’)->user();
// $user->token; (return as your need)
}

Step 6 :- Now, we make Sign-in with Google button. Just copy and paste the below code in your login page.

Note :- You can use fa-fa icon of google instead of google.svg or download it by searching on google by Keyword google SVG icon download.

Thats All. ???

How to Add Sign-in with Facebook feature in Laravel – (Click Here)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

Single Sign-On Implementations: Practical Comparison and Evaluation Guide

This guide expands a short 2015 link list of SSO tools into a practical DevOps reference. You will learn how SSO flows work, how to compare implementations, and how to validate integrations with real commands.

Read More

Keyclock: A Identity & SSO tools

Keycloak: Identity & SSO Tool (IAM in one box) What it is Keycloak is an open-source Identity and Access Management (IAM) platform that provides Single Sign-On (SSO),…

Read More

GitHub Organization Administration Essentials — 2-Hour Tutorial

Last Verified: September 2026Based on: GitHub Organization Administration — Complete Reference Guide and TutorialDuration: 2 hoursAudience: GitHub organization owners, DevOps/platform engineers, developers with delegated administration duties, security administrators, and technical trainers….

Read More

Pomerium Tutorial: Complete End-to-End Guide to Zero-Trust Access, Identity-Aware Proxy, SSO, Kubernetes, SSH and Production Deployment

The tutorial below targets Pomerium Core, the open-source/self-managed edition, using the current v0.33 stable generation as the baseline. Pomerium’s documentation also has a rolling main version, so…

Read More

Principal IAM Consultant: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Principal IAM Consultant** is a senior individual-contributor security specialist who designs, governs, and improves identity and access management (IAM) capabilities across a software or IT organization. The role combines deep technical expertise (SSO, federation, IAM governance, privileged access, cloud identity) with consultative leadership—translating business needs into secure, scalable identity solutions and operating models.

Read More

Senior Identity Specialist: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Senior Identity Specialist** is a senior individual contributor responsible for designing, operating, and continuously improving the organization’s identity and access management (IAM) capabilities across workforce and (where applicable) customer-facing systems. The role ensures that the right people and services have the right access to the right resources at the right time—while minimizing risk, maintaining auditability, and enabling secure productivity.

Read More