Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized -> profile = media.GetProfiles()[0] #1381

Open
fti-sbargule opened this issue Jun 22, 2023 · 0 comments

Comments

@fti-sbargule
Copy link

fti-sbargule commented Jun 22, 2023

code file

from zeep import Client
from zeep.wsse.username import UsernameToken

ptz_wsdl = "/home/suyog/stitcher/PTZcamera_image/PTZcamera_control/python-onvif-zeep/wsdl/ptz.wsdl"
media_wsdl = "/home/suyog/stitcher/PTZcamera_image/PTZcamera_control/python-onvif-zeep/wsdl/media.wsdl"

ip = ""
port = ""
username = ""
password = ""

xaddr = "http://"+ip+":"+port+"/onvif/ptz_service"

media_client = Client(wsdl=media_wsdl, wsse=UsernameToken(
    username, password, use_digest=True))
media = media_client.create_service(
    "{http://www.onvif.org/ver10/media/wsdl}MediaBinding", xaddr)

ptz_client = Client(wsdl=ptz_wsdl, wsse=UsernameToken(
    username, password, use_digest=True))
ptz = ptz_client.create_service(
    "{http://www.onvif.org/ver20/ptz/wsdl}PTZBinding", xaddr)
print("ptz")
print(media.__dir__())
profile = media.GetProfiles()[0]
print("profile")
ptz_config = ptz.GetConfigurationOptions(profile.PTZConfiguration.token)

velocity = {
    "PanTilt": {
        "x": ptz_config.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Min,
        "y": ptz_config.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Min,
    },
}

ptz.ContinuousMove(profile.token, Velocity=velocity)

REQUEST SEND to PTZ camera:-

OPTION:-:http://192.168.10.35:80/onvif/ptz_service
ENVELOPE:-:<Element {http://www.w3.org/2003/05/soap-envelope}Envelope at 0x7f9613422d00>
HTTP HEADERS :-: {'SOAPAction': '"http://www.onvif.org/ver10/media/wsdl/GetProfiles"', 
                          'Content-Type': 'application/soap+xml; charset=utf-8; 
                          action="http://www.onvif.org/ver10/media/wsdl/GetProfiles"'}

Response from camera :-

RESPONSE COD :-: <Response [400]>
RESPONSE     :-:   b'<?xml version="1.0" encoding="UTF-8"?>\r\n<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnsn="http://www.eventextension.com/2011/event/topics" xmlns:extwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:extxsd="http://www.onvifext.com/onvif/ext/ver10/schema" xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:tr2="http://www.onvif.org/ver20/media/wsdl" xmlns:axt="http://www.onvif.org/ver20/analytics"><env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value>\r\n<env:Subcode><env:Value>ter:NotAuthorized</env:Value>\r\n</env:Subcode>\r\n</env:Code>\r\n<env:Reason><env:Text xml:lang="en">The action requested requires authorization and the sender is not authorized</env:Text>\r\n</env:Reason>\r\n</env:Fault>\r\n</env:Body>\r\n</env:Envelope>\r\n'

Error :-

Traceback (most recent call last):
  File "/home/suyog/zeep_demo.py", line 25, in <module>
    profile = media.GetProfiles()[0]
  File "/home/suyog/zeep_onvif/lib/python3.10/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/home/suyog/zeep_onvif/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 138, in send
    return self.process_reply(client, operation_obj, response)
  File "/home/suyog/zeep_onvif/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 232, in process_reply
    return self.process_error(doc, operation)
  File "/home/suyog/zeep_onvif/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 394, in process_error
    raise Fault(
zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized
@fti-sbargule fti-sbargule changed the title zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized GetProfile coll zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized >> profile = media.GetProfiles()[0] Jun 22, 2023
@fti-sbargule fti-sbargule changed the title zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized >> profile = media.GetProfiles()[0] zeep.exceptions.Fault: The action requested requires authorization and the sender is not authorized -> profile = media.GetProfiles()[0] Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant