@defer.inlineCallbacks
    def get_appservice_by_req(self, request):
        try:
            token = request.args["access_token"][0]
            service = yield self.store.get_app_service_by_token(token)
            if not service:
                logger.warn("Unrecognised appservice access token: %s" % (token,))
                raise AuthError(
                    self.TOKEN_NOT_FOUND_HTTP_STATUS,
                    "Unrecognised access token.",
                    errcode=Codes.UNKNOWN_TOKEN
                )
            request.authenticated_entity = service.sender
            defer.returnValue(service)
        except __HOLE__:
            raise AuthError(
                self.TOKEN_NOT_FOUND_HTTP_STATUS, "Missing access token."
            )
dataset/ETHPy150Open matrix-org/synapse/synapse/api/auth.py/Auth.get_appservice_by_req