valhallasw / flask-mwoauth Goto Github PK
View Code? Open in Web Editor NEWFlask blueprint to connect to a MediaWiki OAuth server
License: MIT License
Flask blueprint to connect to a MediaWiki OAuth server
License: MIT License
Deals with the JWT stuff nicely - gets you centralauth ids and stuff that work well with the 'authenticate only' workflows in OAuth. Plus one widely used implementation > 2 split ones!
Thanks for the package, it helped me a lot in handling OAuth with MediaWiki. It works fine, performs OAuth but I am encountering an error at callback url. The error is:
Traceback (most recent call last):
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/jwt/api_jws.py", line 191, in _load
header = json.loads(header_data.decode('utf-8'))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/mwoauth/functions.py", line 264, in identify
leeway=leeway)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/jwt/api_jwt.py", line 84, in decode
payload, _, _, _ = self._load(jwt)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/jwt/api_jws.py", line 193, in _load
raise DecodeError('Invalid header string: %s' % e)
jwt.exceptions.DecodeError: Invalid header string: 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask_mwoauth/__init__.py", line 88, in oauth_authorized
username = self.get_current_user(False)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/flask_mwoauth/__init__.py", line 166, in get_current_user
mwoauth.AccessToken(**session['mwoauth_access_token']))
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/mwoauth/handshaker.py", line 127, in identify
leeway=leeway, user_agent=self.user_agent)
File "/home/rammanoj/.virtualenvs/wikitransfer/lib/python3.5/site-packages/mwoauth/functions.py", line 268, in identify
"content: {0}".format(e))
mwoauth.errors.OAuthException: An error occurred while trying to read json content: Invalid header string: 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte
127.0.0.1 - - [11/Jun/2019 23:41:18] "GET /oauth-callback?oauth_verifier=123123123&oauth_token=asdasdasd HTTP/1.1" 500 -
Hope to find a solution soon
I'm writing an application that uses this module to make modification to a Wikipedia page. The title of the bug is the error message I get from the server.
The code making the request is as follows:
edit_query = {'action': 'edit',
'title': title.encode('utf-8'),
'summary': summary.encode('utf-8'),
'text': new_text.encode('utf-8'),
'token': edit_token
}
if section != '-1':
edit_query['section'] = section
result = mwoauth.request(edit_query)
This code used to work previously (~ 1 year ago).
I think that now all edit requests should be handled as long requests.
Hi,
this is more of a documentation bug. I have posted this question on StackOverflow:
"How to override a Flask blueprint URL?"
Long story short, I would like to know if there is a way to "extend" the blueprint response for the predefined URIs. How can I do it?
The demo.py file only shows the login/logout part. It would be very useful to also have an exemple of request use, beyond request({'action': 'query', 'meta': 'userinfo'}), for instance an example of an edit query.
Hey, I am getting a warning.
Sending requests with default User-Agent. Set 'user_agent' on mwoauth.flask.MWOAuth to quiet this message.
So How to set user-agent to rid this message
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.