Overview
revolution/socialite-discord is a driver package that adds Discord OAuth2 support to Laravel Socialite. Discord is not included among Socialite’s built-in providers. Install this package and you can immediately useSocialite::driver('discord') to add Discord login to your application.
For a general guide on Laravel Socialite, see the Socialite guide.
Installation
Configuration
Register your app in the Discord Developer Portal
Create an application in the Discord Developer Portal and retrieve the Client ID and Client Secret from the OAuth2 section. Add your callback URL (e.g.https://example.com/auth/discord/callback) to the Redirects list.
config/services.php
.env
Basic usage
1
Define routes
Add a redirect route and a callback route to
routes/web.php.2
Create the controller
Scopes
Discord OAuth2 uses scopes to control which data your application can access. The default scope isidentify only.
Saving the user and logging in
A typical callback implementation that persists the user to the database and logs them in:Comparison with other Socialite drivers
This package is implemented usingSocialite::extend(), the official method for adding custom drivers. It exposes the same API as any built-in provider. For details on how custom providers work and how Socialite::extend() is used, see the Socialite guide.
For the latest information, refer to the GitHub repository.