def METHOD_NAME(
    name: str,
    *,
    unauthorized_reason: str | None = None,
    one_time_access: bool = True,
    remove_all_on_success: bool = False,
):
    def _decorator(handler: Handler):
        @functools.wraps(handler)
        async def _wrapper(request: web.Request):
            session = await get_session(request)
            with _access_tokens_cleanup_ctx(session) as access_tokens:
                access: _AccessToken | None = access_tokens.get(name, None)
                if not access:
                    raise web.HTTPUnauthorized(reason=unauthorized_reason)
                access["count"] -= 1  # consume access count
                if access["count"] < 0 or _is_expired(access):
                    raise web.HTTPUnauthorized(reason=unauthorized_reason)
                # update and keep for future accesses (e.g. retry this route)
                access_tokens[name] = access
            # Access granted to this handler
            response = await handler(request)
            if response.status < 400:  # success
                with _access_tokens_cleanup_ctx(session) as access_tokens:
                    if one_time_access:
                        # avoids future accesses by clearing all tokens
                        access_tokens.pop(name, None)
                    if remove_all_on_success:
                        # all access tokens removed
                        access_tokens = {}
            return response
        return _wrapper
    return _decorator