robin-ivi / google-auth
Laravel Google Login Package
1.0.2
2026-04-06 04:01 UTC
Requires
- php: >=8.1
- laravel/socialite: ^5.0
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:
.testdomains are NOT supported- Use
localhostor 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
- User clicks Google Login
- Redirects to Google
- User authenticates
- Callback receives user data
- User is created (if not exists)
- 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!