adoy/oauth2
A framework-agnostic PHP OAuth 2.0 server library that implements authorization and resource servers, common grant types, scopes, and token handling, giving PHP applications a lightweight foundation for secure OAuth2 authentication.
Architecture fit
OAuth2\Client plus grant-type classes (authorization code, client credentials, password, refresh token) and a pluggable token-storage interface. It answers exactly one question: "how do I exchange credentials for a bearer token and attach it to a request?"draft-ietf-oauth-v2-15), its conformance target is a draft, not the standard. Everything we build on it inherits a spec-conformance gap that we — not the vendor — must close. That is acceptable for a trivial authorization-code flow against a permissive IdP; it is not acceptable for anything with a security review attached.Integration feasibility
E_ALL before committing.$_SESSION semantics, multi-node stickiness, and queue/CLI contexts where no session exists.Technical risk
state handling, redirect-URI strictness, and token-endpoint error normalization need to be read line by line rather than assumed.Key questions
league/oauth2-client)? Both are maintained and both are cheaper than adopting this.Stack fit
laravel/socialite (+ socialiteproviders/*) for consumer identity providers, and league/oauth2-client with its provider packages for machine-to-machine and generic OAuth. Both are actively maintained, PSR-compliant, PHP 8-ready, and MIT-licensed.Migration path
OAuthClient::redirect(), ::exchangeCode(), ::refresh(), ::withToken()) and bind adoy/oauth2 behind it in a service provider. Config in config/services.php, secrets in the standard Laravel encrypted env path.league/oauth2-client then becomes a one-class reimplementation plus a provider-package install, not a refactor of every call site.Compatibility
$_SESSION path.Sequencing
league/oauth2-client (+ provider package) against adoy on the same two-week integration spike. Default the recommendation to the maintained option.league/oauth2-client directly and skip the abstraction debt.Maintenance
Support
Scaling
league/oauth2-client communities have already solved.Failure modes
invalid_grant and mask revocation as a transient error, driving retry storms.Ramp-up
TPM recommendation: Do not adopt. Score 13.2 with 0 dependents, a draft-spec foundation, LGPL-2.1 entanglement on a codebase we will inevitably patch, and no security response path is a clear no for anything customer-facing. Frame the opportunity (41.7) correctly: it signals a genuine niche for a minimal OAuth client, not a mandate to use a fourteen-year-old one. Re-run the spike against league/oauth2-client; only revisit adoy if a hard constraint — air-gapped, no-dependency policy, or a pinned legacy runtime — eliminates the maintained options.
How can I help you explore Laravel packages today?