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 Distributions
mwoauth-0.2.3.zip
(11.3 kB
view details)
mwoauth-0.2.3.tar.gz
(6.0 kB
view details)
File details
Details for the file mwoauth-0.2.3.zip
.
File metadata
- Download URL: mwoauth-0.2.3.zip
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b19c999ce576611854f0f44dd983ff5727c6aa2c1e66d927366bafb11a89860 |
|
MD5 | a2ba8d51860e7c980193dec938e623d1 |
|
BLAKE2b-256 | d8e8f8a7d0d0731af4f39e33e4063833044477311ba06a6597722f6e15b637b8 |
File details
Details for the file mwoauth-0.2.3.tar.gz
.
File metadata
- Download URL: mwoauth-0.2.3.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30be9371cadfaeb07967e5b968c72c1919f72d43ddeb26abb67a36bf17f261d |
|
MD5 | 83ee0d4314afbdc3e99a882787d9d8b6 |
|
BLAKE2b-256 | 513a8eb7edbf8529554891c2abf46d13ffb0017af24f4aeb2a892e6689f4e4ef |