Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

3rd-Party Providers: Login with Google

Premium
10 min read

The next feature we will work on is Google Login. Our client decided that they want the users to log in via Google. This means we must add Google as a Socialite provider.

Reminder: This course is about the process and not much about the code. For the code, we will use the example from our separate older Tutorial about Google Sign In on Laravel Daily.

The main emphasis in this lesson will be on the process of making that feature work in a multi-server and multi-developer environment: how to set up an external 3rd-party provider to make it work locally and on other servers and write automated tests for it.

The general plan of action is this:

  • Installing Socialite
  • Configuring Google provider
  • Adding Socialite Controller
  • Adding Routes
  • Adding a Button to Login/Registration pages
  • Setting up our project in Google Identity
  • Testing integration locally
  • Writing tests
  • Preparing for Staging/Production environments

Let's get to work!

Note: Just a reminder - as for every new feature, we are creating a GitHub issue and a new branch here, and you should, too.


Installing Socialite

Installing Socialite is as simple as running a composer command:

composer require laravel/socialite

Once that is done, we need to configure it.


Configuring Google Provider

Let's add the Google provider to our config/services.php file.

config/services.php

// ...
 
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('GOOGLE_REDIRECT'),
],
 
// ...

Next, we need to create a list of...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…