title: Flask endpoint issue - decorator login check
body: <p>I'm getting an issue</p>
  
  <pre><code>BuildError: Could not build url for endpoint 'home'. Did you mean 'Welcome' instead?
  </code></pre>
  
  <p>Welcome is another function in the application (first function defined)</p>
  
  <pre><code>def loginRequired(func):
      def wrapper():
          access_token = session.get('access_token')
          if access_token is None:
              return redirect(url_for('login'))
          else:
              return func
  
      return wrapper
  @app.route('/Homepage')
  @loginRequired
  def home():    
      return render_template('Homepage.html', title="Title")
  
  @app.route('/login')
  def login():
      callback = url_for('authorized', _external=True)
      return google.authorize(callback=callback)
  
  
  @app.route(REDIRECT_URI)
  @google.authorized_handler
  def authorized(resp):
      access_token = resp['access_token']
      session['access_token'] = access_token, ''
      return redirect(url_for('home'))
  
  
  @google.tokengetter
  def get_access_token():
      return session.get('access_token')
  </code></pre>
  
  <p>Traceback message :</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__
      return self.wsgi_app(environ, start_response)
    File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "C:\Python27\lib\site-packages\flask_oauth.py", line 433, in decorated
      return f(*((data,) + args), **kwargs)
    File "C:\Users\Barry\PycharmProjects\FYP\welcome.py", line 169, in authorized
      return redirect(url_for('home'))
    File "C:\Python27\lib\site-packages\flask\helpers.py", line 312, in url_for
      return appctx.app.handle_url_build_error(error, endpoint, values)
    File "C:\Python27\lib\site-packages\flask\app.py", line 1641, in handle_url_build_error
      reraise(exc_type, exc_value, tb)
    File "C:\Python27\lib\site-packages\flask\helpers.py", line 305, in url_for
      force_external=external)
    File "C:\Python27\lib\site-packages\werkzeug\routing.py", line 1758, in build
      raise BuildError(endpoint, values, method, self)
  BuildError: Could not build url for endpoint 'home'. Did you mean 'Welcome' instead?
  </code></pre>
  
  <p>Google is doing the sign in okay(being prompted), but i cant seem to be able to get the redirect working for home.
  If i change home to another function (that isent login required) then the redirect works</p>
  
  <p>Also if i place the lines</p>
  
  <pre><code>access_token = session.get('access_token')
  if access_token is None:
      return redirect(url_for('login'))
  </code></pre>
  
  <p>inside the home function and not include the decorator  it works</p>
  
  <p>Thoughts?</p>