title: Restful API with authentication
body: <p>I try to built an API for my web2py application.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  auth.settings.allow_basic_login = True
  
  @auth.requires_login()
  @request.restful()
  def api():
      response.view = 'generic.json'
  
      def GET(tablename, id):
          if not tablename == 'division':
              raise HTTP(400)
  
  
          result = db(db.division.title == id).select()
  
          return dict(result = result)
  
  return locals()
  </code></pre>
  
  <p>But everytime I try to connect via curl I get this answer:</p>
  
  <pre><code>You are being redirected &lt;a href=\"/my_manager/login?_next=/my_manager/api/get_all_divisions/1.json\"&gt;here&lt;/a&gt;
  </code></pre>
  
  <p>When I comment out this line</p>
  
  <pre><code>@auth.requires_login()
  </code></pre>
  
  <p>everythink works fine.</p>
  
  <p>I've searched for hints, but didn't found any helpful information about this topic so far.</p>
  
  <p>Any help is really appreciated.</p>