2017 © Pedro Peláez
 

library oauthclient

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

image

mediawiki/oauthclient

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

  • Saturday, July 28, 2018
  • by mediawiki
  • Repository
  • 20 Watchers
  • 3 Stars
  • 7,687 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 19 % Grown

The README.md

![Latest Stable Version] ![License], (*1)

mediawiki/oauthclient

PHP OAuth client for use with Wikipedia and other MediaWiki-based wikis running the OAuth extension., (*2)

Installation

$ composer require mediawiki/oauthclient

Usage

For working example code, see the demo directory., (*3)

General usage is as follows:, (*4)

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

    $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 );, (*6)

  2. Retrieve the authentication URL and the Request Token:, (*7)

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

  3. Store the Request Token somewhere and send the user to the authentication URL., (*9)

  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:, (*10)

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

  5. Once you've got an Access Token you can store it and use it to make authenticated requests to the wiki., (*12)

    To get the user's identity:, (*13)

    $ident = $client->identify( $accessToken );, (*14)

    To make any API call:, (*15)

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

Running tests

composer install --prefer-dist
composer test

History

The code is a refactored version of Stype/mwoauth-php, which in turn is partially based on Andy Smith's OAuth library. Some code is taken from wikimedia/slimapp. See CHANGELOG.md for more details., (*17)


The Versions

28/07 2018

dev-master

9999999-dev https://www.mediawiki.org/wiki/oauthclient-php

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

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

The Development Requires

by Chris Steipp

03/06 2016

0.1.2

0.1.2.0 https://www.mediawiki.org/wiki/oauthclient-php

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

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Chris Steipp

16/01 2016

0.1.1

0.1.1.0 https://www.mediawiki.org/wiki/oauthclient-php

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

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Chris Steipp

24/10 2015

0.1.0

0.1.0.0 https://www.mediawiki.org/wiki/oauthclient-php

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

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Chris Steipp