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 Distribution

mwoauth-0.3.7.tar.gz (10.1 kB view details)

Uploaded Source

Built Distributions

mwoauth-0.3.7-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

mwoauth-0.3.7-py2-none-any.whl (14.1 kB view details)

Uploaded Python 2

File details

Details for the file mwoauth-0.3.7.tar.gz.

File metadata

  • Download URL: mwoauth-0.3.7.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • 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.7.tar.gz
Algorithm Hash digest
SHA256 9e0d70a1fa6f452584de1cb853ae6c11f41233549f7839cfb879f99410f6ad46
MD5 04838b65d2e92787488584340e35693d
BLAKE2b-256 90aa14c6006b06eff2fb22ccba1a1e8d7c8cbf14b772bf57954fc369f01c0650

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mwoauth-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ef3e86ab965848e71162990cb4e9c580408a098df793fc08511e062d12f068d4
MD5 959d8ef9d5c3df47b7888da2667c2ee2
BLAKE2b-256 124ad45ef95a5d7b1516fa5a416a25ec1fdd3c921af3f49929733e9b6c963e66

See more details on using hashes here.

File details

Details for the file mwoauth-0.3.7-py2-none-any.whl.

File metadata

  • Download URL: mwoauth-0.3.7-py2-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 2
  • 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.7-py2-none-any.whl
Algorithm Hash digest
SHA256 af4e9dcbf397255dc0a31dea7655a9b9e5de312fcfed816e80622437c5cf072d
MD5 6021e48182880fc6848044493ff75ba4
BLAKE2b-256 3f95d90ed0f960725648141343d5bd0667a9ed1dc78907c09fa27b8477cff0c4

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