一个通用的MediaWiki OAuth握手助手。
项目描述
MediaWiki OAuth库
mwoauth 是一个开源许可(MIT)库,旨在为安装了 OAuth 扩展 的 MediaWiki 安装提供一个简单的 OAuth 握手方式。
兼容python 3.x
使用pip安装: pip install mwoauth
用法
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))
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
mwoauth-0.4.0.tar.gz (10.3 kB 查看哈希值)
构建分发
mwoauth-0.4.0-py3-none-any.whl (12.9 kB 查看哈希值)