Flask-restful app fails when authentication is enabled
<p>I'm getting this error whenever I try and enable authentication using flask_httpauth for my flask_restful project:</p>

<pre><code>AttributeError: 'function' object has no attribute 'as_view'
</code></pre>

<p>Here's a very basic example:
apicontroller.py:</p>

<pre><code>from flask_restful import Resource, Api
from flasktest import api, app
from flask_httpauth import HTTPTokenAuth

auth = HTTPTokenAuth()

@auth.login_required
class ApiController(Resource):
    def get(self):
        return True

api.add_resource(ApiController, '/api/apicontroller')
</code></pre>

<p><strong>init</strong>.py:</p>

<pre><code>from flask import render_template
from flask import Flask, request, render_template, session, flash, redirect, url_for, jsonify
from flask_restful import Resource, Api, reqparse, fields
from flask_httpauth import HTTPTokenAuth


app = Flask(__name__)

api = Api(app)

import flasktest.apicontroller
</code></pre>

<p>Whenever I decorate the controller class with <code>@auth.login_required</code>, it fails with the mentioned error. How can I fix this?</p>

<p>I believe that you cannot not apply decorators to class.</p>

<p>To solve that:</p>

<pre><code>from flask_restful import Resource, Api
from flasktest import api, app

from flask_httpauth import HTTPTokenAuth

auth = HTTPTokenAuth()

class ApiController(Resource):
    decorators = [auth.login_required]

    def get(self):
        return True

api.add_resource(ApiController, '/api/apicontroller')
</code></pre>

python flask-restful flask-httpauth