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

# 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


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.8.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mwoauth-0.3.8.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.15.0 CPython/3.8.10

File hashes

Hashes for mwoauth-0.3.8.tar.gz
Algorithm Hash digest
SHA256 08daf4edabaa0f95a845f98e5707de7316a8383a9625f20ae768b035991c36ac
MD5 d02865fcded4ae8e736c6a05047d1210
BLAKE2b-256 009ba4e57553500ac5ecf513b49beb5ebccffae2a83a3ff4ec53b3f2acee6e41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mwoauth-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.26.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.15.0 CPython/3.8.10

File hashes

Hashes for mwoauth-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0fe65bc42aa78f29da33df4c851d12e3b6c41820772bb51b18945f7ea710dca2
MD5 e83ab785caa189caeb7a55890c15b6be
BLAKE2b-256 e91a258e40d74281aefafa1e1b3258fa982ae5b9fd03b5ebbdb829076fecb0c9

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