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.6.tar.gz
(5.8 kB
view details)
Built Distributions
mwoauth-0.2.6-py3.4.egg
(13.3 kB
view details)
File details
Details for the file mwoauth-0.2.6.tar.gz
.
File metadata
- Download URL: mwoauth-0.2.6.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
817c53848416cd742582db59f08c20880d6284d7bac4984182acddb4b6140db7
|
|
MD5 |
5c4886a5b8e4391ce2906cde336776c4
|
|
BLAKE2b-256 |
eb8f6fb1adc4445d19a466c2bd7c40eed0f1be6a8b19c58f974a26b5412774c8
|
File details
Details for the file mwoauth-0.2.6-py3.4.egg
.
File metadata
- Download URL: mwoauth-0.2.6-py3.4.egg
- Upload date:
- Size: 13.3 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 |
cbd4366e1f3f2aefefae088d3b83a2c3b9d1a452af082017d969d13d7a219273
|
|
MD5 |
0fde2b3e071c6cedcedbf5a757a3c674
|
|
BLAKE2b-256 |
4270654663e4a950e150735906e4427e85ffe1fa04da1e56d7c0a1535226c06e
|
File details
Details for the file mwoauth-0.2.6-py3-none-any.whl
.
File metadata
- Download URL: mwoauth-0.2.6-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
97d3af20fd0655cb48789e7479562b510ecacbded976c376a6cbb50e08d7131b
|
|
MD5 |
98f6942070f92c2758076fe7b53067fc
|
|
BLAKE2b-256 |
fec2a67a876613f4a12c7a8002a0be755546f7bf74673c23388fd81c8f4a1ecc
|