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.10.tar.gz
(6.3 kB
view details)
Built Distributions
mwoauth-0.2.10-py3.5.egg
(22.9 kB
view details)
File details
Details for the file mwoauth-0.2.10.tar.gz
.
File metadata
- Download URL: mwoauth-0.2.10.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d60e5d7ffea91e036b830191810c4c288b22e4bcd3f466eae53eaf9da6f57505
|
|
MD5 |
35748b9340379320ea20e1ee49323be0
|
|
BLAKE2b-256 |
8a6441fd7eb0e6aea9cfd58fde74f0385e5c2a0e558221ceb6d9ec573eb9d53d
|
File details
Details for the file mwoauth-0.2.10-py3.5.egg
.
File metadata
- Download URL: mwoauth-0.2.10-py3.5.egg
- Upload date:
- Size: 22.9 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 |
2d4a03c47006c1a0c9394897309cdb50875656893eec65b6845bb63b84a0a3a7
|
|
MD5 |
2f0e6d696722f64f47ab033639b1b61f
|
|
BLAKE2b-256 |
1ccce852998bc58cd6075fad29ae438743c84c3b59f6ed4c80b078a8529bd293
|
File details
Details for the file mwoauth-0.2.10-py3-none-any.whl
.
File metadata
- Download URL: mwoauth-0.2.10-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4a4dbb015f8e6d14d7ae2bf399621f74240758a1644cfb3a4f5ee564a34a6832
|
|
MD5 |
109a5a3083987d357521c8ef638e0203
|
|
BLAKE2b-256 |
18135e61ae00adbf3550093f745a132ddc21c2fc1b382de2335e900f7341d0cd
|