Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.1
2 Name: mwoauth
3 Version: 0.4.0
4 Summary: A generic MediaWiki OAuth handshake helper.
5 Home-page: https://github.com/mediawiki-utilities/python-mwoauth
6 Author: Aaron Halfaker / Filippo Valsorda
7 Author-email: [email protected]
8 License: MIT
9 Classifier: Development Status :: 4 - Beta
10 Classifier: Topic :: Security
11 Classifier: License :: OSI Approved :: MIT License
12 Classifier: Topic :: Software Development :: Libraries :: Python Modules
13 License-File: LICENSE
14 Requires-Dist: PyJWT>=1.0.1
15 Requires-Dist: oauthlib
16 Requires-Dist: requests
17 Requires-Dist: requests-oauthlib
18 Provides-Extra: flask
19 Requires-Dist: flask; extra == "flask"
20
21 MediaWiki OAuth Library
22 =======================
23
24 ``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 <https://www.mediawiki.org/wiki/Extension:OAuth>`_ installed.
25
26 **Compatible with python 3.x**
27
28 **Install with pip:** ``pip install mwoauth``
29
30 **Documentation:** http://pythonhosted.org/mwoauth
31
32 Usage
33 =====
34
35 .. code-block:: python
36
37 from mwoauth import ConsumerToken, Handshaker
38
39 # Construct a "consumer" from the key/secret provided by MediaWiki
40 import config
41 consumer_token = ConsumerToken(config.consumer_key, config.consumer_secret)
42
43 # Construct handshaker with wiki URI and consumer
44 handshaker = Handshaker("https://en.wikipedia.org/w/index.php",
45 consumer_token)
46
47 # Step 1: Initialize -- ask MediaWiki for a temporary key/secret for user
48 redirect, request_token = handshaker.initiate()
49
50 # Step 2: Authorize -- send user to MediaWiki to confirm authorization
51 print("Point your browser to: %s" % redirect) #
52 response_qs = input("Response query string: ")
53
54 # Step 3: Complete -- obtain authorized key/secret for "resource owner"
55 access_token = handshaker.complete(request_token, response_qs)
56 print(str(access_token))
57
58 # Step 4: Identify -- (optional) get identifying information about the user
59 identity = handshaker.identify(access_token)
60 print("Identified as {username}.".format(**identity))
61