Implement a JWT header into base client

- adds a base client
- adds a notifications client

These do not proxy onto genuine methods. This pull request is the basic implication of the API Client. Still needs a few things before is ready, notably proper logging and actual API endpoints to hook into.

Basic premise is to deliver the JWT tokens required for Notify API authentication so we can discuss the implementation/premise.
This commit is contained in:
Martyn Inglis
2015-12-11 16:57:00 +00:00
parent e25ca0e434
commit 6deaa61011
11 changed files with 256 additions and 7 deletions

36
app/main/errors.py Normal file
View File

@@ -0,0 +1,36 @@
from flask import jsonify
from . import main
@main.app_errorhandler(400)
def bad_request(e):
return jsonify(error=str(e.description)), 400
@main.app_errorhandler(401)
def unauthorized(e):
error_message = "Unauthorized, authentication token must be provided"
return jsonify(error=error_message), 401, [('WWW-Authenticate', 'Bearer')]
@main.app_errorhandler(403)
def forbidden(e):
error_message = "Forbidden, invalid authentication token provided"
return jsonify(error=error_message), 403
@main.app_errorhandler(404)
def page_not_found(e):
return jsonify(error=e.description or "Not found"), 404
@main.app_errorhandler(429)
def limit_exceeded(e):
return jsonify(error=str(e.description)), 429
@main.app_errorhandler(500)
def internal_server_error(e):
# TODO: log the error
return jsonify(error="Internal error"), 500