title: Combining Flask Blueprints with Flask-JWT
body: <p>I am developing a <code>Flask</code> 0.12 app with Blueprints and I am trying to use <code>Flask-JWT</code> (0.3.2) for authentication.</p>
  
  <p>None of the tutorials that I can see for Flask-JWT use Blueprints.</p>
  
  <p>There is a usually a block of code in each example, that does something like this:</p>
  
  <pre><code>app = Flask(__name__)
  jwt = JWT(app, authenticate, identity)
  </code></pre>
  
  <p>In a blueprinted flask app the structure tends to be more like this:</p>
  
  <p><strong>__init__.py</strong>:</p>
  
  <pre><code>from swarm.controllers.main import main
  from swarm.controllers.grid import grid
  from swarm.controllers.address import address
  
  def create_app(object_name):
      app = Flask(__name__)
      ...
      app.register_blueprint(main)
      app.register_blueprint(grid)
      app.register_blueprint(address)
  </code></pre>
  
  <p><strong>controllers/main.py:</strong></p>
  
  <pre><code>main = Blueprint('main', __name__)
  </code></pre>
  
  <p><strong>controllers/grid.py:</strong></p>
  
  <pre><code>grid = Blueprint('grid', __name__)
  </code></pre>
  
  <p><strong>controllers/address.py:</strong></p>
  
  <pre><code>address = Blueprint('address', __name__)
  </code></pre>
  
  <p>How would I reference <code>Flask-JWT</code> and use its decorators in the controllers?</p>
  
  <p>It might prove easier to answer this question by showing how to add JWT decorators to a standard example such as <a href="https://github.com/pallets/flask/tree/master/examples/blueprintexample" rel="nofollow noreferrer">blueprintexample</a> in the flask source code o <a href="https://github.com/postrational/rest_api_demo" rel="nofollow noreferrer">Michał Karzyński's REST API demo</a>.</p>