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 3.x
Install with pip: pip install mwoauth
Documentation: http://pythonhosted.org/mwoauth
Usage
from mwoauth import ConsumerToken, Handshaker
# Construct 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.4.0.tar.gz
(10.3 kB
view details)
Built Distribution
mwoauth-0.4.0-py3-none-any.whl
(12.9 kB
view details)
File details
Details for the file mwoauth-0.4.0.tar.gz
.
File metadata
- Download URL: mwoauth-0.4.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22e3403e748e70146f8eccc1430fe542c9f9c4ff677eff424a52e644f6d8f7c5 |
|
MD5 | fee930be38f356297d60d7612fc23b0e |
|
BLAKE2b-256 | 19b4702647c01cbf430814a66bdba11084eafcc7e8eac02bfd0bdd743db29fb1 |
File details
Details for the file mwoauth-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: mwoauth-0.4.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fed9bc7d6bbabb5f691b918af0ac844e13c9b75d5fa51a898f36d54d798b5fe1 |
|
MD5 | 14ce89a2dc0137e34641c57f1eaf53c1 |
|
BLAKE2b-256 | 255d40c62f5f81181f454ad9dcd664c8e227842828b8e653f701f8237520dfa9 |