laravel-oauth maintained by sameoldnick
Description
Integrates Laravel Socialite with your app’s auth.
Author
Last update
2026/06/05 20:44
(dev-main)
License
Downloads
13
Tags
Laravel OAuth
Integrates Laravel Socialite with your app's authentication flow, including account linking, account relinking, registration/login gate checks, and stack-specific response handling.
Features
- Built-in OAuth flow routes and handlers
- Built-in clients: GitHub, Google, Twitter
- Uses
config/oauth.php(instead ofconfig/services.php) for provider credentials - Account linking table + model (
oauth_providers) - Install command to scaffold app-owned OAuth services and responses
- Contracts for full customization (gate checks, user resolver, registrar, response types)
- Events for connected/disconnected/signed-in lifecycle hooks
- Testing helpers via
OAuth::fake()
Requirements
- PHP 8.4+
- Laravel 11.x, 12.x, or 13.x
laravel/socialite5.27+
Installation
- Install the package:
composer require sameoldnick/laravel-oauth
- Publish config and migrations:
php artisan vendor:publish --tag=oauth-config
php artisan vendor:publish --tag=oauth-migrations
- Run migrations:
php artisan migrate
- Scaffold app-level OAuth services and responses:
php artisan oauth:install --stack=fortify
- Add provider credentials to
.env(examples):
GITHUB_OAUTH_ENABLED=true
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
GITHUB_REDIRECT_URI="${APP_URL}/oauth/callback/github"
GOOGLE_OAUTH_ENABLED=true
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GOOGLE_REDIRECT_URI="${APP_URL}/oauth/callback/google"
TWITTER_OAUTH_ENABLED=true
TWITTER_CLIENT_ID=...
TWITTER_CLIENT_SECRET=...
TWITTER_REDIRECT_URI="${APP_URL}/oauth/callback/twitter"
- Ensure the generated app provider is registered.
The install command attempts to add App\\Providers\\OAuthServiceProvider::class to bootstrap/providers.php. If not added automatically, register it manually.
Wiki
All extended documentation lives in the wiki.