I am using flask-mwoauth
to create a simple application in Flask using OAuth authentication on Mediawiki (and Wikipedia in particular).
flask-mwoauth
is a blueprint that provides some convenience methods to interact with Mediawiki Extensions:OAuth and adds the following URIs:
/login
- runs the OAuth handshake and returns the user to/
/login?next=/someurl
will return the user to/someurl
/logout
- clears the users' access tokens/logout?next=/someurl
will return the user to/someurl
/oauth-callback
- callback from MW to finish the handshake
The users' OAuth key and secret are stored in the session.
I would like to be able to create custom responses for some of this custom URIs. Take for example /logout
, the definition of the response in very simple (__init__.py#L56
):
@self.bp.route('/logout')
def logout():
session['mwo_token'] = None
session['username'] = None
if 'next' in request.args:
return redirect(request.args['next'])
return "Logged out!"
I would like to define in my application the route /logout
with a custom response (for example, rendering a template), however if I use the blueprint then the route @app.route("/logout")
is ignored.
What I would like to know if it is possible to "extend" the blueprint in the sense that I can define a route /logout
in my app, call the original method from the blueprint and then serve a customized response.