PHPackages                             krombox/oauth2-wordpress - 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. krombox/oauth2-wordpress

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

krombox/oauth2-wordpress
========================

WordPress OAuth 2.0 Client Provider for The PHP League OAuth2-Client

0.1.2(2y ago)115.0k—0%6[1 issues](https://github.com/krombox/oauth2-wordpress/issues)2MITPHP

Since Sep 19Pushed 2y ago2 watchersCompare

[ Source](https://github.com/krombox/oauth2-wordpress)[ Packagist](https://packagist.org/packages/krombox/oauth2-wordpress)[ RSS](/packages/krombox-oauth2-wordpress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (2)

WordPress provider for OAuth 2.0 Client
=======================================

[](#wordpress-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/002b38aac92e40eb106dfae0581330323e64232063c04e2534de833c975c3d99/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6b726f6d626f782f6f61757468322d776f726470726573732e7376673f7374796c653d666c61742d737175617265)](https://github.com/krombox/oauth2-wordpress/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/d99be7350ef45696364bfdcfe0b4aad16e3e19c7a6e87f4be0ad049e061dd2dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b726f6d626f782f6f61757468322d776f726470726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/krombox/oauth2-wordpress)

This package provides WordPress OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

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

[](#installation)

To install, use composer:

```
composer require krombox/oauth2-wordpress

```

Prerequirements
---------------

[](#prerequirements)

1. [WP OAuth Server](https://wordpress.org/plugins/oauth2-provider/) plugin installed and [configured](https://wordpress.org/plugins/oauth2-provider/#faq)

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\Krombox\OAuth2\Client\Provider\WordPress` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Krombox\OAuth2\Client\Provider\WordPress([
    'clientId'          => '{wordpress-client-id}',
    'clientSecret'      => '{wordpress-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
    'domain'            => 'https://example.com',
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s!', $user->getId());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [Roman Kapustian](https://github.com/krombox)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/krombox/oauth2-wordpress/blob/master/LICENSE) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity55

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 ~1168 days

Total

3

Last Release

827d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0894b03bcb914edee2b5771808f9609fd65f750b49ee67f662e77f663e956fac?d=identicon)[krombox](/maintainers/krombox)

---

Top Contributors

[![krombox](https://avatars.githubusercontent.com/u/3314883?v=4)](https://github.com/krombox "krombox (5 commits)")

---

Tags

clientwordpressoauthoauth2authorizationauthorisation

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/krombox-oauth2-wordpress/health.svg)

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

###  Alternatives

[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[league/oauth2-instagram

Instagram OAuth 2.0 Client Provider for The PHP League OAuth2-Client

761.0M31](/packages/league-oauth2-instagram)[stevenmaguire/oauth2-salesforce

Salesforce OAuth 2.0 Client Provider for The PHP League OAuth2-Client

311.6M3](/packages/stevenmaguire-oauth2-salesforce)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[dalpras/oauth2-gotowebinar

LogMeIn GoToWebinar OAuth 2.0 Client Provider for the PHP League's OAuth 2.0 Client

1244.3k](/packages/dalpras-oauth2-gotowebinar)

PHPackages © 2026

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