Skip to content

Repository files navigation

MediaWiki OAuth Library

mwoauth is an open licensed (MIT) library designed to provide a simple means to performing an OAuth handshake with a MediaWiki installation with the OAuth Extension installed.

Compatible with python 3.x

Install with pip:pip install mwoauth

Documentation:http://pythonhosted.org/mwoauth

Usage

frommwoauthimportConsumerToken, Handshaker# Construct a "consumer" from the key/secret provided by MediaWikiimportconfigconsumer_token=ConsumerToken(config.consumer_key, config.consumer_secret)
# Construct handshaker with wiki URI and consumerhandshaker=Handshaker("https://en.wikipedia.org/w/index.php",
consumer_token)
# Step 1: Initialize -- ask MediaWiki for a temporary key/secret for userredirect, request_token=handshaker.initiate()
# Step 2: Authorize -- send user to MediaWiki to confirm authorizationprint("Point your browser to: %s"%redirect) #response_qs=input("Response query string: ")
# Step 3: Complete -- obtain authorized key/secret for "resource owner"access_token=handshaker.complete(request_token, response_qs)
print(str(access_token))
# Step 4: Identify -- (optional) get identifying information about the useridentity=handshaker.identify(access_token)
print("Identified as {username}.".format(**identity))

About

A generic MediaWiki OAuth handshake helper for Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages