sameoldnick / laravel-oauth
Integrates Laravel Socialite with your app’s auth.
v1.0.0
2026-06-03 23:52 UTC
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0||^13.0
- laravel/socialite: ^5.27
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/fortify: ^1.37
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^11.0.0||^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
README
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.