PHPackages                             league/oauth2-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. league/oauth2-server

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

league/oauth2-server
====================

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

9.3.0(5mo ago)6.6k136.0M—2.3%1.1k[55 issues](https://github.com/thephpleague/oauth2-server/issues)[21 PRs](https://github.com/thephpleague/oauth2-server/pulls)20MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Aug 27Pushed 3mo ago200 watchersCompare

[ Source](https://github.com/thephpleague/oauth2-server)[ Packagist](https://packagist.org/packages/league/oauth2-server)[ Docs](https://oauth2.thephpleague.com/)[ GitHub Sponsors](https://github.com/sephster)[ RSS](/packages/league-oauth2-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (123)Used By (20)Security (1)

PHP OAuth 2.0 Server
====================

[](#php-oauth-20-server)

[![Latest Version](https://camo.githubusercontent.com/07374488d628793eb4be22229129e52f084200d135bf3c5a010fc977e5332a36/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65616775652f6f61757468322d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth2-server/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://github.com/thephpleague/oauth2-server/workflows/tests/badge.svg)](https://github.com/thephpleague/oauth2-server/actions)[![Coverage Status](https://camo.githubusercontent.com/4d19482eb9b0faee73dd2f8cab55c349f1eac3113f2cf4838a5e2630f9065c22/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f6f61757468322d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth2-server/code-structure)[![Quality Score](https://camo.githubusercontent.com/5bbb71f2086c51eda336d8f4629178eb670b1c4058b39d07b9cda56125f95d5a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f6f61757468322d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth2-server)[![Total Downloads](https://camo.githubusercontent.com/a78ed55a3198bcb7603d0635eeaa157c19cdd0b7561aed7e238fc35e9c51fa03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6f61757468322d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/oauth2-server)

`league/oauth2-server` is a standards compliant implementation of an [OAuth 2.0](https://tools.ietf.org/html/rfc6749) authorization server written in PHP which makes working with OAuth 2.0 trivial. You can easily configure an OAuth 2.0 server to protect your API with access tokens, or allow clients to request new access tokens and refresh them.

Out of the box it supports the following grants:

- Authorization code grant
- Client credentials grant
- Device authorization grant
- Implicit grant
- Refresh grant
- Resource owner password credentials grant

The following RFCs are implemented:

- [RFC6749 "OAuth 2.0"](https://tools.ietf.org/html/rfc6749)
- [RFC6750 "The OAuth 2.0 Authorization Framework: Bearer Token Usage"](https://tools.ietf.org/html/rfc6750)
- [RFC7519 "JSON Web Token (JWT)"](https://tools.ietf.org/html/rfc7519)
- [RFC7636 "Proof Key for Code Exchange by OAuth Public Clients"](https://tools.ietf.org/html/rfc7636)
- [RFC8628 "OAuth 2.0 Device Authorization Grant](https://tools.ietf.org/html/rfc8628)

This library was created by Alex Bilbie. Find him on Twitter at [@alexbilbie](https://twitter.com/alexbilbie).

Requirements
------------

[](#requirements)

The latest version of this package supports the following versions of PHP:

- PHP 8.2
- PHP 8.3
- PHP 8.4
- PHP 8.5

The `openssl` and `json` extensions are also required.

All HTTP messages passed to the server should be [PSR-7 compliant](https://www.php-fig.org/psr/psr-7/). This ensures interoperability with other packages and frameworks.

Installation
------------

[](#installation)

```
composer require league/oauth2-server

```

Documentation
-------------

[](#documentation)

The library documentation can be found at . You can contribute to the documentation in the [gh-pages branch](https://github.com/thephpleague/oauth2-server/tree/gh-pages/).

Testing
-------

[](#testing)

The library uses [PHPUnit](https://phpunit.de/) for unit tests.

```
vendor/bin/phpunit

```

Continuous Integration
----------------------

[](#continuous-integration)

We use [Github Actions](https://github.com/features/actions), [Scrutinizer](https://scrutinizer-ci.com/), and [StyleCI](https://styleci.io/) for continuous integration. Check out [our](https://github.com/thephpleague/oauth2-server/blob/master/.github/workflows/tests.yml) [configuration](https://github.com/thephpleague/oauth2-server/blob/master/.scrutinizer.yml) [files](https://github.com/thephpleague/oauth2-server/blob/master/.styleci.yml) if you'd like to know more.

Community Integrations
----------------------

[](#community-integrations)

- [Drupal](https://www.drupal.org/project/simple_oauth)
- [Laravel Passport](https://github.com/laravel/passport)
- [OAuth 2 Server for CakePHP 3](https://github.com/uafrica/oauth-server)
- [OAuth 2 Server for Mezzio](https://github.com/mezzio/mezzio-authentication-oauth2)
- [OAuth 2 Server Bundle (Symfony)](https://github.com/thephpleague/oauth2-server-bundle)
- [Heimdall for CodeIgniter 4](https://github.com/ezralazuardy/heimdall)

Changelog
---------

[](#changelog)

See the [project changelog](https://github.com/thephpleague/oauth2-server/blob/master/CHANGELOG.md)

Contributing
------------

[](#contributing)

Contributions are always welcome. Please see [CONTRIBUTING.md](https://github.com/thephpleague/oauth2-server/blob/master/CONTRIBUTING.md) and [CODE\_OF\_CONDUCT.md](https://github.com/thephpleague/oauth2-server/blob/master/CODE_OF_CONDUCT.md) for details.

Support
-------

[](#support)

Bugs and feature request are tracked on [GitHub](https://github.com/thephpleague/oauth2-server/issues).

If you have any questions about OAuth *please* open a ticket here; please **don't** email the address below.

Security
--------

[](#security)

If you discover any security related issues, please email `andrew@noexceptions.io` instead of using the issue tracker.

License
-------

[](#license)

This package is released under the MIT License. See the bundled [LICENSE](https://github.com/thephpleague/oauth2-server/blob/master/LICENSE) file for details.

Credits
-------

[](#credits)

This code is principally developed and maintained by [Andy Millington](https://twitter.com/Sephster).

Between 2012 and 2017 this library was developed and maintained by [Alex Bilbie](https://alexbilbie.com/).

PHP OAuth 2.0 Server is one of many packages provided by The PHP League. To find out more, please visit [our website](https://thephpleague.com).

Special thanks to [all of these awesome contributors](https://github.com/thephpleague/oauth2-server/contributors).

Additional thanks go to the [Mozilla Secure Open Source Fund](https://wiki.mozilla.org/MOSS/Secure_Open_Source) for funding a security audit of this library.

The initial code was developed as part of the [Linkey](http://linkey.blogs.lincoln.ac.uk) project which was funded by [JISC](http://jisc.ac.uk) under the Access and Identity Management programme.

###  Health Score

83

—

ExcellentBetter than 100% of packages

Maintenance76

Regular maintenance activity

Popularity86

Widely adopted with strong download metrics

Community61

Healthy contributor diversity

Maturity98

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 57.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~85 days

Total

119

Last Release

174d ago

Major Versions

6.1.1 → 7.0.02018-02-18

4.1.7 → 7.2.02018-06-23

7.4.0 → 8.0.02019-07-13

8.5.4 → 9.0.0-RC12024-03-27

8.5.5 → 9.2.02025-02-15

PHP version history (14 changes)0.2PHP &gt;=5.3.0

3.0PHP &gt;=5.4.0

5.0.0-RC1PHP &gt;=5.5.9

6.0.0PHP &gt;=5.6.0

7.0.0PHP &gt;=7.0.0

8.0.0PHP &gt;=7.1.0

8.1.0PHP &gt;=7.2.0

8.2.0PHP ^7.3 || ^8.0

8.2.3PHP ^7.2 || ^8.0

8.5.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0

8.5.1PHP ^8.0

9.0.0-RC1PHP ~8.1.0 || ~8.2.0 || ~8.3.0

9.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

9.3.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/534693?v=4)[Frank de Jonge](/maintainers/frankdejonge)[@frankdejonge](https://github.com/frankdejonge)

![](https://www.gravatar.com/avatar/3a5327d87a2a2d37a9412d5706442399763d86cb773f81adbe58c8d749393e2d?d=identicon)[alexbilbie](/maintainers/alexbilbie)

![](https://www.gravatar.com/avatar/24ff986b9d3ca464465e5d890dcac7ec85b23d6b6739ab90918402d6dcce807e?d=identicon)[sephster](/maintainers/sephster)

---

Top Contributors

[![alexbilbie](https://avatars.githubusercontent.com/u/77991?v=4)](https://github.com/alexbilbie "alexbilbie (1691 commits)")[![Sephster](https://avatars.githubusercontent.com/u/1457058?v=4)](https://github.com/Sephster "Sephster (889 commits)")[![hafezdivandari](https://avatars.githubusercontent.com/u/56585913?v=4)](https://github.com/hafezdivandari "hafezdivandari (111 commits)")[![juliangut](https://avatars.githubusercontent.com/u/1104131?v=4)](https://github.com/juliangut "juliangut (56 commits)")[![lucadegasperi](https://avatars.githubusercontent.com/u/820687?v=4)](https://github.com/lucadegasperi "lucadegasperi (15 commits)")[![lookyman](https://avatars.githubusercontent.com/u/3863468?v=4)](https://github.com/lookyman "lookyman (15 commits)")[![ssigwart](https://avatars.githubusercontent.com/u/1426848?v=4)](https://github.com/ssigwart "ssigwart (12 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (12 commits)")[![dhrrgn](https://avatars.githubusercontent.com/u/149921?v=4)](https://github.com/dhrrgn "dhrrgn (11 commits)")[![erickjth](https://avatars.githubusercontent.com/u/287978?v=4)](https://github.com/erickjth "erickjth (11 commits)")[![eugene-borovov](https://avatars.githubusercontent.com/u/341783?v=4)](https://github.com/eugene-borovov "eugene-borovov (11 commits)")[![filecage](https://avatars.githubusercontent.com/u/698854?v=4)](https://github.com/filecage "filecage (11 commits)")[![iansltx](https://avatars.githubusercontent.com/u/472804?v=4)](https://github.com/iansltx "iansltx (11 commits)")[![toopay](https://avatars.githubusercontent.com/u/534245?v=4)](https://github.com/toopay "toopay (7 commits)")[![marc-mabe](https://avatars.githubusercontent.com/u/302689?v=4)](https://github.com/marc-mabe "marc-mabe (6 commits)")[![Hywan](https://avatars.githubusercontent.com/u/946104?v=4)](https://github.com/Hywan "Hywan (6 commits)")[![fizzka](https://avatars.githubusercontent.com/u/2384736?v=4)](https://github.com/fizzka "fizzka (6 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (6 commits)")[![michaelhogg](https://avatars.githubusercontent.com/u/6292810?v=4)](https://github.com/michaelhogg "michaelhogg (5 commits)")[![JC5](https://avatars.githubusercontent.com/u/5889984?v=4)](https://github.com/JC5 "JC5 (5 commits)")

---

Tags

oauthoauth2oauth2-serverphpapiauthAuthenticationserveroauthoauth2authorizationoauth 2.0secureresourceprotectauthorisationoauth 2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/league-oauth2-server/health.svg)

```
[![Health](https://phpackages.com/badges/league-oauth2-server/health.svg)](https://phpackages.com/packages/league-oauth2-server)
```

###  Alternatives

[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.2k1](/packages/chervand-yii2-oauth2-server)[ezralazuardy/heimdall

Painless OAuth 2.0 Server for CodeIgniter 4

454.2k](/packages/ezralazuardy-heimdall)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.0M3](/packages/auth0-login)[auth0/symfony

Symfony SDK for Auth0 Authentication and Management APIs.

128738.1k](/packages/auth0-symfony)[auth0/wordpress

WordPress Plugin for Auth0

17419.5k](/packages/auth0-wordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
