一个通用的MediaWiki OAuth握手助手。

mwoauth的Python项目详细描述


MediaWiki OAuth库

mwoauth是一个开放式许可(mit)库,旨在提供一种简单的方法,在安装了OAuth Extension的mediawiki安装中执行oauth握手。

与python 2.7和3.x兼容

使用pip安装:pip install mwoauth

文档:http://pythonhosted.org/mwoauth

用法

frommwoauthimportConsumerToken,Handshakerfromsix.movesimportinput# For compatibility between python 2 and 3# Consruct a "consumer" from the key/secret provided by MediaWikiimportconfigconsumer_token=ConsumerToken(config.consumer_key,config.consumer_secret)# Construct handshaker with wiki URI and consumerhandshaker=Handshaker("https://en.wikipedia.org/w/index.php",consumer_token)# Step 1: Initialize -- ask MediaWiki for a temporary key/secret for userredirect,request_token=handshaker.initiate()# Step 2: Authorize -- send user to MediaWiki to confirm authorizationprint("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 useridentity=handshaker.identify(access_token)print("Identified as {username}.".format(**identity))

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在收到远程通知时对iBeacon进行java扫描   尝试在Java中实现MD5哈希的算法   java getLastLocation最近有多久了?   java线程创建侦听器   swing Java JComboBox接受ArrayList,但不显示ArrayList的项   构建服务器上的java XML验证速度较慢   Tomcat无法识别java中的更改(Intellij配置)   java 5中引入泛型的原因   java意图。Android中的额外_流   for循环Java直接遍历数组而不是数组变量   java内部类中的两个声明构造函数   java试图使用子文本字段在JPanel上设置边框   java如何允许在Android WebView中进行条带签出?   在Java中,如何将数字从一个类转移到另一个类?   从任务栏关闭浏览器时的java会话   java有没有一种自动化的方法来确保代码的所有部分都经过单元测试?   2DArrays Java编码查找数组