def dispatch(self, request, api_key, *args, **kwargs):
        try:
            api_user = ApiUser.get('ApiUser-%s' % api_key)
        except ResourceNotFound:
            return HttpResponse(status=401)

        if api_user.doc_type != 'ApiUser' or not api_user.has_permission(PERMISSION_POST_SMS):
            return HttpResponse(status=401)

        return super(IncomingBackendView, self).dispatch(request, api_key, *args, **kwargs)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/views.py/IncomingBackendView.dispatch/original