league/oauth2-client
league/oauth2-client is a PHP library providing a base for OAuth 2.0 integrations. It includes a GenericProvider for Bearer-token services, follows RFC 6749, and can be extended for provider-specific behavior.
league/oauth2-client when you need a provider Socialite does not cover, deeper control over the OAuth flow, or a provider-agnostic base for multiple integrations.Consider it when:
league/oauth2-* client, or you are prepared to build and maintain a small provider client.Look elsewhere when:
Executive summary: league/oauth2-client is a mature, MIT-licensed OAuth 2.0 client base that lets us add third-party sign-in and account-connection features without building security-sensitive protocol code ourselves. It is not a turnkey login product and is not Laravel-specific. The recommendation is to use it selectively: Laravel Socialite for common social login, and league/oauth2-client plus provider clients for custom or less-common OAuth2 integrations.
Engineering summary: The package is PSR-compliant, supports PHP 7.1 through 8.5, and covers authorization-code flow, PKCE, refresh tokens, access tokens, and resource-owner retrieval. We still own state/CSRF validation, token persistence and encryption, provider-client selection, consent UX, error handling, and account linking. Start with one provider pilot, define token-storage and security requirements, and budget for provider-specific edge cases. This lowers integration risk and time-to-market versus custom OAuth, while avoiding over-reliance on a package that is not a full identity solution.
How can I help you explore Laravel packages today?