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
Release history Release notifications | RSS feed
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.2.9.tar.gz
(6.2 kB
view details)
Built Distributions
mwoauth-0.2.9-py3.5.egg
(15.6 kB
view details)
File details
Details for the file mwoauth-0.2.9.tar.gz
.
File metadata
- Download URL: mwoauth-0.2.9.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
46a61baea4258670653dd108a8546e580c24282ba849551a7863ccad10d411cb
|
|
MD5 |
d0ae731acfcf383c551b5f610d0b0279
|
|
BLAKE2b-256 |
7588f40280b3d7947b804127e51f1e22a71e9e3d0911e596e9d05f958cdc82e6
|
File details
Details for the file mwoauth-0.2.9-py3.5.egg
.
File metadata
- Download URL: mwoauth-0.2.9-py3.5.egg
- Upload date:
- Size: 15.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
17da4de8f4a7de18f9ba7d4798c2a374d6c7c5919844a5278327a422d7cd47fb
|
|
MD5 |
528ed6ced6364e0363e0cdce980bc386
|
|
BLAKE2b-256 |
77d5fbc7e31c395aedb88739e27f2bf7f0deb041cf9059844a6c950f804765ba
|
File details
Details for the file mwoauth-0.2.9-py3-none-any.whl
.
File metadata
- Download URL: mwoauth-0.2.9-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
eda5a1b8cc1788afd3501b4660a0656da2db16d8634e6557e5949bed5e10cae1
|
|
MD5 |
ebc49c44c589868f2511b9055da82ee6
|
|
BLAKE2b-256 |
a0f2aeb89f75f6acd27c87961f2a80736c01d414c43168f567aec61ca367397b
|