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.8.tar.gz
(6.1 kB
view details)
Built Distributions
mwoauth-0.2.8-py3.5.egg
(15.0 kB
view details)
File details
Details for the file mwoauth-0.2.8.tar.gz
.
File metadata
- Download URL: mwoauth-0.2.8.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
6578474c41e2789e15905ad566ad3122e388fa5d0e84dee69692ac1ba244af3a
|
|
MD5 |
92f5229706593a46bb962175b7a5d13a
|
|
BLAKE2b-256 |
27c3086f85ef23caf4c2e64c59c38334455efdfc54cd5fc0a7a7d6e8c5366c2c
|
File details
Details for the file mwoauth-0.2.8-py3.5.egg
.
File metadata
- Download URL: mwoauth-0.2.8-py3.5.egg
- Upload date:
- Size: 15.0 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 |
4ebdced50d9c0756377b01ceaf2db4650de0eda1d74964a096d0ef4218417d13
|
|
MD5 |
32cd105a17717fcbb50ff3da9abec0f1
|
|
BLAKE2b-256 |
771cf8ab486b63256036f44be7bc015b445b6d0bfbac8011627ced94ba9dfff0
|
File details
Details for the file mwoauth-0.2.8-py2-none-any.whl
.
File metadata
- Download URL: mwoauth-0.2.8-py2-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7351fd78da0c1e8919e1893eedbc562e3601716ba138cc3016f699866499c558
|
|
MD5 |
9b3a0f2d2d4a1ba13a4810eadda9d3f5
|
|
BLAKE2b-256 |
891efc85df391d5ed5def8cb8d3e40fa2f04d63acdf6d98ce1c045f51cf17b63
|