PHPackages                             p9d/oauth2-toolkit - 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. p9d/oauth2-toolkit

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

p9d/oauth2-toolkit
==================

v0.2.1(1mo ago)0431MITPHPPHP ^8.4CI passing

Since Aug 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/pizzaminded/oauth2-toolkit)[ Packagist](https://packagist.org/packages/p9d/oauth2-toolkit)[ RSS](/packages/p9d-oauth2-toolkit/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (10)Versions (8)Used By (0)

`p9d/oauth2-toolkit`
====================

[](#p9doauth2-toolkit)

Tools to deal with OAuth2/OpenID protocols.

Use this package if your app needs to handle OAuth2/OIDC credentials to third party services, and you need something to manage them in a organized way.

```
$providers = [
    'your-provider-name-here' => new \P9D\OAuth2Toolkit\OpenIdConfigurationProvider(
        clientId: 'XXXXXXX',
        clientSecret: 'YYYYYYYY',
        configurationEndpoint: 'https:///realms/ACME/.well-known/openid-configuration'
    )

    /**
     * If service does not expose openid-configuration (or you want to override it), you can pass URLs directly:
     */
    'your-another-provider-name' => new \P9D\OAuth2Toolkit\OpenIdConfigurationProvider(
        clientId: 'XXXXXXX',
        clientSecret: 'YYYYYYYY',
        tokenEndpoint: 'https://example.com/oauth2/token',
        authorizationEndpoint: 'https://example.com/oauth2/autorize',
        jwksEndpoint: 'https://example.com/oauth2/jwks',
    )
];

$factory = new \P9D\OAuth2Toolkit\OpenIdConfigurationFactory(
    $providers,
    \Symfony\Component\HttpClient\HttpClient::create()
);

# Access provider config via:
$provider = $factory->createForProvider('your-provider-name-here');
```

Provider configuration:
-----------------------

[](#provider-configuration)

- `clientId` - *required*
- `clientSecret` - *required*
- `configurationEndpoint` - URL to [OpenID Discovery Endpoint](https://openid.net/specs/openid-connect-discovery-1_0.html)
- `tokenEndpoint` - [OAuth2 Token Endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.2)
- `authorizationEndpoint` - [OAuth2 Authorization Endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.1)
- `jwksEndpoint` - `jwks_uri` endpoint in OpenID Discovery spec.

Note

You can use `tokenEndpoint`, `authorizationEndpoint`, `jwksEndpoint` either with both configuration Endpoint defined or not. When defined, these properties will **override** values received from configuration. All of these properties are optional, you can skip any of those you do not use.

Methods available in `OpenIdConfigurationService`
-------------------------------------------------

[](#methods-available-in-openidconfigurationservice)

### `getAuthorizationUrl(): string`

[](#getauthorizationurl-string)

Returns a link user should be redirected to login.

#### parameters:

[](#parameters)

- `grantType`,
- `redirectUri`
- `clientId` - *optional* - when not passed, value passed in `client_id` from configuration will be used.
- `scope` - *optional*
- `state` - *optional*

### `getJwks(): array`

[](#getjwks-array)

Returns an array of JSON Web Key Set.

### `getAccessToken(): AccessToken`

[](#getaccesstoken-accesstoken)

Exchanges code to access tokens.

#### parameters:

[](#parameters-1)

- `grantType`
- `code` - *optional* when using `client_credentials`

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~108 days

Recently: every ~124 days

Total

7

Last Release

47d ago

PHP version history (2 changes)v0.0.1PHP ^8.3

v0.2.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13077797?v=4)[Mikolaj Czajkowski](/maintainers/pizzaminded)[@pizzaminded](https://github.com/pizzaminded)

---

Top Contributors

[![pizzaminded](https://avatars.githubusercontent.com/u/13077797?v=4)](https://github.com/pizzaminded "pizzaminded (39 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/p9d-oauth2-toolkit/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M736](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

515100.5k3](/packages/web-auth-webauthn-framework)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

66529.9k11](/packages/web-auth-webauthn-symfony-bundle)[storyblok/php-content-api-client

PHP Client for Storyblok Content API

11176.5k10](/packages/storyblok-php-content-api-client)[sylius/core

Sylius e-commerce core. It integrates all components.

10157.7k43](/packages/sylius-core)

PHPackages © 2026

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