Skip to main content

A generic MediaWiki OAuth handshake helper.

Project description

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 2.7 and 3.x

Install with pip: pip install mwoauth

Documentation: http://pythonhosted.org/mwoauth

Usage

from mwoauth import ConsumerToken, Handshaker
from six.moves import input # For compatibility between python 2 and 3

# Consruct a "consumer" from the key/secret provided by MediaWiki
import config
consumer_token = ConsumerToken(config.consumer_key, config.consumer_secret)

# Construct handshaker with wiki URI and consumer
handshaker = Handshaker("https://en.wikipedia.org/w/index.php",
                        consumer_token)

# Step 1: Initialize -- ask MediaWiki for a temporary key/secret for user
redirect, request_token = handshaker.initiate()

# Step 2: Authorize -- send user to MediaWiki to confirm authorization
print("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 user
identity = handshaker.identify(access_token)
print("Identified as {username}.".format(**identity))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mwoauth-0.3.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distributions

mwoauth-0.3.0-py3.5.egg (23.7 kB view details)

Uploaded Egg

mwoauth-0.3.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file mwoauth-0.3.0.tar.gz.

File metadata

  • Download URL: mwoauth-0.3.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mwoauth-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9d71c9ee6fb758e4b206249ae9214a9801a39045e8ea84e3ba0d8d05250564d2
MD5 dded2c300e100c9eaaf94df20e4da956
BLAKE2b-256 5954efb2a18987dab83602071013444b161d168434dd7b8be55da2f78fa1be0f

See more details on using hashes here.

File details

Details for the file mwoauth-0.3.0-py3.5.egg.

File metadata

  • Download URL: mwoauth-0.3.0-py3.5.egg
  • Upload date:
  • Size: 23.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.15.0 CPython/3.5.1+

File hashes

Hashes for mwoauth-0.3.0-py3.5.egg
Algorithm Hash digest
SHA256 bea2533857c1e27e730002cfbca57ba7155a25012b0751039e993bf492a697c2
MD5 c94697179ac8d9697d5e5c281b0153e4
BLAKE2b-256 b48018d7b28b2ad707864fcf5f63c96248d80dccb07ef0fc4946e3e4a0bc668a

See more details on using hashes here.

File details

Details for the file mwoauth-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mwoauth-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5c88c40aaccd9302e34e9a14e3a792e53b196f631ad8e5b9fa366620a8ace0f
MD5 3404fa561ca1087291252d9eb2c12bcf
BLAKE2b-256 615801dcb05d683ed552b2eef3349c997005cb9e6d2366dec612322a5a2c850e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page