def check_api_key(f):
    @wraps(f)
    def wrapper(request, *args, **kwds):
        try:
            data = json.loads(request.body.decode("utf-8"))
        except __HOLE__:
            return make_error("could not parse request body")

        api_key = str(data.get("api_key", ""))
        if api_key == "":
            return make_error("wrong api_key")

        try:
            user = User.objects.get(profile__api_key=api_key)
        except User.DoesNotExist:
            return make_error("wrong api_key")

        request.json = data
        request.user = user
        return f(request, *args, **kwds)

    return wrapper
dataset/ETHPy150Open healthchecks/healthchecks/hc/api/decorators.py/check_api_key