original_docstring:  Prompt user to authenticate with password or Mapzen if necessary.
          
docstring: Prompt user to authenticate with password or Mapzen if necessary.
docstring_tokens: Prompt user to authenticate with password or Mapzen if necessary .
code: def wrapper(*args, **kwargs):
          ''' Prompt user to authenticate with password or Mapzen if necessary.
          '''
          if current_app.config['MAPZEN_APP_ID'] is None:
              auth = request.authorization
              if not auth or (auth.username, auth.password) != hardcoded_auth:
                  return Response(
                      'Could not verify your access level for that URL.\n'
                      'You have to login with proper credentials',
                      401, {'WWW-Authenticate': 'Basic realm="Login Required"'}
                      )
  
          else:
              envelope_path = url_for('ODES.get_envelope', envelope_id=basename(request.path))
              is_envelope = bool(envelope_path == request.path)
              is_returning = bool('been here before' in session)
              should_see_interstitial = is_envelope and not is_returning
  
              access_token = session.get('token', {}).get('access_token', None)
              user_id = session.get('id', {}).get('id', None)
  
              if access_token is None or user_id is None:
                  return make_401_response(should_see_interstitial)
  
              resp = get(mapzen_currdev_url,
                         headers={'Authorization': 'Bearer {}'.format(access_token)})
  
              if resp.status_code in range(400, 499):
                  return make_401_response(should_see_interstitial)
  
          return untouched_route(*args, **kwargs)
code_tokens: def wrapper ( * args , ** kwargs ) : if current_app . config [ 'MAPZEN_APP_ID' ] is None : auth = request . authorization if not auth or ( auth . username , auth . password ) != hardcoded_auth : return Response ( 'Could not verify your access level for that URL.\n' 'You have to login with proper credentials' , 401 , { 'WWW-Authenticate' : 'Basic realm="Login Required"' } ) else : envelope_path = url_for ( 'ODES.get_envelope' , envelope_id = basename ( request . path ) ) is_envelope = bool ( envelope_path == request . path ) is_returning = bool ( 'been here before' in session ) should_see_interstitial = is_envelope and not is_returning access_token = session . get ( 'token' , { } ) . get ( 'access_token' , None ) user_id = session . get ( 'id' , { } ) . get ( 'id' , None ) if access_token is None or user_id is None : return make_401_response ( should_see_interstitial ) resp = get ( mapzen_currdev_url , headers = { 'Authorization' : 'Bearer {}' . format ( access_token ) } ) if resp . status_code in range ( 400 , 499 ) : return make_401_response ( should_see_interstitial ) return untouched_route ( * args , ** kwargs )
short_docstring: Prompt user to authenticate with password or Mapzen if necessary.
short_docstring_tokens: Prompt user to authenticate with password or Mapzen if necessary .
comment: ''' Prompt user to authenticate with password or Mapzen if necessary.
          '''