robin-ivi/google-auth

Laravel Google Login Package

Maintainers

Package info

github.com/robin-ivi/google-auth

pkg:composer/robin-ivi/google-auth

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

1.0.2 2026-04-06 04:01 UTC

This package is auto-updated.

Last update: 2026-04-06 04:09:17 UTC


README

Simple & plug-and-play Google Login package for Laravel using Socialite. Just install, add .env keys, and you're ready to go๐Ÿ”ฅ

๐Ÿ“ฆ Features

  • โœ… Google Login (OAuth 2.0)
  • โœ… Auto User Registration
  • โœ… Session-based Authentication
  • โœ… Minimal Setup (Only .env)
  • โœ… Clean & Lightweight Package

๐Ÿ› ๏ธ Installation

Step 1: Install via Composer

composer require robin-ivi/google-auth

Step 2: Install Socialite

composer require laravel/socialite

โš™๏ธ Configuration

Step 3: Add Google Credentials in .env

GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REDIRECT_URI=http://127.0.0.1:8000/auth/google/callback

Step 4: Update config/services.php

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URI'),
],

Step 5: Clear Config Cache

php artisan config:clear
php artisan cache:clear

๐Ÿ”‘ Google Console Setup

Go to Google Cloud Console:

  • Create OAuth Client ID
  • Application Type: Web Application

Add Authorized Redirect URI:

http://127.0.0.1:8000/auth/google/callback

โš ๏ธ Note:

  • .test domains are NOT supported
  • Use localhost or real domain only

๐Ÿš€ Usage

Visit the login route:

http://127.0.0.1:8000/auth/google

๐Ÿ”„ Available Routes

Route Description
/auth/google Redirect to Google
/auth/google/callback Handle callback

๐Ÿ‘ค How It Works

  1. User clicks Google Login
  2. Redirects to Google
  3. User authenticates
  4. Callback receives user data
  5. User is created (if not exists)
  6. User is logged in automatically

๐Ÿงช Testing

Run the Laravel server:

php artisan serve

Then open:

http://127.0.0.1:8000/auth/google

โ— Common Issues & Fixes

1. Session store not set

โœ” Use web middleware

2. invalid_client (401)

โœ” Check Client ID / Secret โœ” Check Redirect URI exact match

3. Invalid redirect domain

โŒ .test not allowed โœ” Use 127.0.0.1 or real domain

๐Ÿ“ Package Structure

src/
 โ”œโ”€โ”€ Controllers/
 โ”‚   โ””โ”€โ”€ GoogleController.php
 โ”œโ”€โ”€ routes/
 โ”‚   โ””โ”€โ”€ web.php
 โ”œโ”€โ”€ GoogleAuthServiceProvider.php

๐Ÿ”ฅ Future Updates

  • ๐Ÿ”น Multiple Providers (Facebook, GitHub)
  • ๐Ÿ”น API Support (JWT)
  • ๐Ÿ”น Role-based Redirect
  • ๐Ÿ”น Avatar Storage

๐Ÿค Contributing

Pull requests are welcome! For major changes, open an issue first.

๐Ÿ“„ License

MIT License

๐Ÿ‘จโ€๐Ÿ’ป Author

Krishna Mishra GitHub: https://github.com/robin-ivi

โญ Support

If you like this package, give it a star โญ on GitHub!