Discord (Socialite Provider)

Discord OAuth2 provider for Laravel Socialite — add "Sign in with Discord" to any Laravel app.

SDK
Composer
v4.2.0
42stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
31/100Needs Attention
Development Activity4
Maintenance20
Community28
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture75
Code Quality78
Innovation55
Learning Curve88

A drop-in Discord OAuth2 driver for Laravel Socialite, part of the community-maintained Socialite Providers collection. It extends Socialite with a discord driver so you can add “Sign in with Discord” to a Laravel application with a few lines of configuration.

The provider handles the full OAuth2 authorization-code flow against Discord’s endpoints and maps the returned Discord user into Socialite’s standard user object — exposing id, nickname (with legacy discriminator handling), name, email, and a correctly formatted avatar URL, including animated GIF avatars.

What You Get

  • A discord driver for Laravel Socialite implementing the OAuth2 authorization-code flow
  • Automatic mapping of Discord users to Socialite’s standard user object (id, nickname, name, email, avatar)
  • Correct avatar URL formatting including animated GIF avatars and configurable default extensions
  • A withConsent() helper and configurable scopes for fine-grained control of the consent prompt

Common Use Cases

  • Adding “Sign in with Discord” to a Laravel web app or API
  • Building community/gaming platforms where users authenticate with their Discord identity
  • Linking a Discord account to an existing user for bot or server integrations

Under The Hood

Architecture — The package is intentionally tiny: Provider.php extends SocialiteProviders\Manager\OAuth2\AbstractProvider, overriding getAuthUrl, getTokenUrl, getUserByToken, and mapUserToObject to target Discord’s https://discord.com/api OAuth2 and /users/@me endpoints; DiscordExtendSocialite.php is the listener that registers the driver on Socialite’s SocialiteWasCalled event. Avatar formatting lives in formatAvatar, which inspects the raw avatar hash to pick a GIF or static extension.

Tech Stack — Pure PHP 8.0+ built on socialiteproviders/manager (^4.4) and Guzzle’s RequestOptions for HTTP. It has no build tooling of its own; PSR-4 autoloading maps SocialiteProviders\Discord\ to the package root.

Code Quality — The code is idiomatic and compact, following the same conventions as every other Socialite Providers package, which keeps it predictable. There are no unit tests in the repo — correctness relies on the shared manager base class and the uniformity of the provider pattern.

API Design — Developer experience is excellent: registration is one event listener and a config/services.php block, after which usage is identical to Laravel’s first-party Socialite drivers (Socialite::driver('discord')->redirect()). The withConsent() fluent helper and additional config keys give sensible escape hatches without added boilerplate.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search