Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

mwoauth-0.3.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

mwoauth-0.3.1-py2.7.egg (23.5 kB view details)

Uploaded Egg

File details

Details for the file mwoauth-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mwoauth-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2cf60117848502bef727e1a6b28340330f1c1a0c641e60fb2d15c8524a98aa7
MD5 c8df7be1e07d878e5c383c5873d4163c
BLAKE2b-256 cdab5b1ec959295d8f738066d649e72a1fba54ed33ba0615fd8fb945d8592ef1

See more details on using hashes here.

File details

Details for the file mwoauth-0.3.1-py2.7.egg.

File metadata

  • Download URL: mwoauth-0.3.1-py2.7.egg
  • Upload date:
  • Size: 23.5 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

Hashes for mwoauth-0.3.1-py2.7.egg
Algorithm Hash digest
SHA256 039cf6367d18cdf127763a428a938543c5da2f058f2968bacc59b93efb0b72ff
MD5 435393b14efafd1d6dd318374944b1ab
BLAKE2b-256 894886dc9b87e491ae784bfe62662f3c6f3107ac7737552ccc155366cfe37ee1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page