def decorated_view(*args, **kwargs): api_key = request.values.get("api_key", None) if api_key is not None: user = Account.pull_by_api_key(api_key) if user is not None: if login_user(user, remember=False): return fn(*args, **kwargs) # else raise Api401Error("An API Key is required to access this.")
def decorated_view(*args, **kwargs): api_key = request.values.get("api_key", None) if api_key: user = Account.pull_by_api_key(api_key) if user is not None: if login_user(user, remember=False): return fn(*args, **kwargs) # else abort(401) # no api key, which is ok return fn(*args, **kwargs)