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

Uploaded Source

Built Distribution

mwoauth-0.2.7-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mwoauth-0.2.7.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mwoauth-0.2.7.tar.gz
Algorithm Hash digest
SHA256 bd734fd041a9d46792d0bd3bbe64771e1b37aa6283cefa5c46470704b694175d
MD5 db6f9324bddf3c0ccd631b998906a263
BLAKE2b-256 6add968d78dd7cfffdba43cccc1c705f0e21c8fa4102d437944777708b784076

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mwoauth-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e5ba0cb6a93a35587fbb0020a5593895c8a13bdb145c0af55ce329a94e3fb1
MD5 587d30b294cfa856e79fe62dc3b8e9e4
BLAKE2b-256 74ec8a71e1bd9631f480b93064f539937fe71099f2ac488eebf61b378a06c83d

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