PHPackages                             mediawiki/oauthclient - 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. mediawiki/oauthclient

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

mediawiki/oauthclient
=====================

PHP OAuth client for use with Wikipedia and other MediaWiki-based wikis running the OAuth extension

3.0.0(3w ago)11180.2k↑13.1%77GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Oct 24Pushed 1w ago16 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-oauthclient-php)[ Packagist](https://packagist.org/packages/mediawiki/oauthclient)[ Docs](https://www.mediawiki.org/wiki/oauthclient-php)[ RSS](/packages/mediawiki-oauthclient/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (13)Versions (14)Used By (7)

[![Latest Stable Version](https://camo.githubusercontent.com/74bf5699ede8b3756f07af7928930d363c5ec1079312de2ded7a6235e730ed15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6564696177696b692f6f61757468636c69656e742e7376673f7374796c653d666c6174)](https://packagist.org/packages/mediawiki/oauthclient)[![License](https://camo.githubusercontent.com/06f546a2d42a7e9a3d9ab1e1a1f2112383f2a7ae7b7dd9b76f57bcbfa52f4858/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6564696177696b692f6f61757468636c69656e742e7376673f7374796c653d666c6174)](https://github.com/wikimedia/mediawiki-oauthclient-php/blob/master/COPYING)

mediawiki/oauthclient
=====================

[](#mediawikioauthclient)

PHP [OAuth](https://en.wikipedia.org/wiki/OAuth) client for use with [Wikipedia](https://www.wikipedia.org) and other MediaWiki-based wikis running the [OAuth extension](https://www.mediawiki.org/wiki/Extension:OAuth).

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

[](#installation)

```
$ composer require mediawiki/oauthclient

```

Usage
-----

[](#usage)

*For working example code, see the [demo](demo/) directory.*

General usage is as follows:

1. Create a new Client with consumer key that you've registered with the wiki. Setting an user agent is highly encouraged.

    ```
    $conf = new ClientConfig( 'https://example.org/w/index.php?title=Special:OAuth' );
    $conf->setConsumer( new Consumer(
        'e331e186b64a938591e7614170814a75',
        '9b61abdfa2b88f05670af3919302b12bbc6a6e10'
    ) );
    $conf->setUserAgent( 'MyCoolApp MediaWikiOAuthClient/1.0' );
    $client = new Client( $conf );

    ```
2. Retrieve the authentication URL and the Request Token:

    ```
    list( $authUrl, $requestToken ) = $client->initiate();

    ```
3. Store the Request Token somewhere and send the user to the authentication URL.
4. When the user comes back from the wiki they'll arrive at your callback URL, and the query string will contain an `oauth_verifier` key. Use this to retrieve an Acccess Token:

    ```
    $accessToken = $client->complete( $requestToken,  $_GET['oauth_verifier'] );

    ```
5. Once you've got an Access Token you can store it and use it to make authenticated requests to the wiki.

    To get the user's identity:

    ```
    $ident = $client->identify( $accessToken );

    ```

    To make any API call:

    ```
    $userInfo = $client->makeOAuthCall(
         $accessToken,
         "https://example.org/w/api.php?action=query&meta=userinfo&uiprop=rights&format=json"
    );

    ```

Running tests
-------------

[](#running-tests)

```
composer install --prefer-dist
composer test

```

History
-------

[](#history)

The code is a refactored version of [Stype/mwoauth-php](https://github.com/Stype/mwoauth-php), which in turn is partially based on [Andy Smith's OAuth library](https://code.google.com/p/oauth/). Some code is taken from [wikimedia/slimapp](https://github.com/wikimedia/wikimedia-slimapp). See CHANGELOG.md for more details.

---

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance97

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~303 days

Total

13

Last Release

21d ago

Major Versions

0.1.2 → 1.0.02019-01-23

1.2.0 → 2.0.02023-03-30

2.3.0 → 3.0.02026-07-27

PHP version history (5 changes)1.0.0PHP &gt;=5.6.99

1.1.0PHP ^7.2.9

1.2.0PHP &gt;=7.2.9

2.0.0PHP &gt;=7.4

3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b94d9718c06ec7c3fd7a104bc44966fb7464b9ec7411582343ea35a7a6a85f08?d=identicon)[mediawiki](/maintainers/mediawiki)

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

---

Top Contributors

[![tgr](https://avatars.githubusercontent.com/u/145412?v=4)](https://github.com/tgr "tgr (18 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (16 commits)")[![samwilson](https://avatars.githubusercontent.com/u/213655?v=4)](https://github.com/samwilson "samwilson (10 commits)")[![MatmaRex](https://avatars.githubusercontent.com/u/160413?v=4)](https://github.com/MatmaRex "MatmaRex (7 commits)")[![bd808](https://avatars.githubusercontent.com/u/6469?v=4)](https://github.com/bd808 "bd808 (6 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (6 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (3 commits)")[![urbanecm](https://avatars.githubusercontent.com/u/10050467?v=4)](https://github.com/urbanecm "urbanecm (2 commits)")[![ebernhardson](https://avatars.githubusercontent.com/u/558434?v=4)](https://github.com/ebernhardson "ebernhardson (2 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (2 commits)")[![GlazerMann](https://avatars.githubusercontent.com/u/17836560?v=4)](https://github.com/GlazerMann "GlazerMann (2 commits)")[![ZabeMath](https://avatars.githubusercontent.com/u/35405030?v=4)](https://github.com/ZabeMath "ZabeMath (1 commits)")[![atdt](https://avatars.githubusercontent.com/u/376462?v=4)](https://github.com/atdt "atdt (1 commits)")[![bawolff](https://avatars.githubusercontent.com/u/6529932?v=4)](https://github.com/bawolff "bawolff (1 commits)")[![octfx](https://avatars.githubusercontent.com/u/6594492?v=4)](https://github.com/octfx "octfx (1 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (1 commits)")[![supertassu](https://avatars.githubusercontent.com/u/9721638?v=4)](https://github.com/supertassu "supertassu (1 commits)")[![xSavitar](https://avatars.githubusercontent.com/u/4872561?v=4)](https://github.com/xSavitar "xSavitar (1 commits)")[![0x010C](https://avatars.githubusercontent.com/u/7341555?v=4)](https://github.com/0x010C "0x010C (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mediawiki-oauthclient/health.svg)

```
[![Health](https://phpackages.com/badges/mediawiki-oauthclient/health.svg)](https://phpackages.com/packages/mediawiki-oauthclient)
```

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k382.4M3.7k](/packages/symfony-cache)[google/auth

Google Auth Library for PHP

1.4k302.1M240](/packages/google-auth)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[simplesamlphp/saml2

SAML2 PHP library from SimpleSAMLphp

30418.3M44](/packages/simplesamlphp-saml2)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

12514.0M164](/packages/web-auth-webauthn-lib)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k21](/packages/tempest-framework)

PHPackages © 2026

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