如何获取 MIPSDK 的 ImageServer 的授权令牌
How to get authorization token for MIPSDK's ImageServer
我想连接到里程碑 sdk (MIPSDK) 的管理服务器并获取 MIPSDK 的 imageServer 的令牌。我正在使用套接字,但不知道该怎么做。
这是我到目前为止所做的
import ssl
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.x.xx', 443))
s = ssl.wrap_socket(s, keyfile=None, cert_reqs=ssl.CERT_NONE, certfile=None, server_side=False, ssl_version=ssl.PROTOCOL_TLS)
s.settimeout(10);
s.sendall("POST /ManagementServer/ServerCommandService.svc HTTP/1.1\r\nHost: 192.168.xx.xx\r\nAuthorization:Basic\ xxxxxx\r\nContent-Length: 2048\r\n\r\n")
new = s.recv(4096)
print new
甚至可以从 python 客户端登录到管理服务器吗?
DotNet 中有内置 classes/functionalities,但我无法找到任何 python 实现。
环顾四周后,我终于设法从 milestone imageServer 获得了令牌。
import ssl
import socket
import uuid
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('server-ip', 443))
v = uuid.uuid4()
s = ssl.wrap_socket(s, keyfile=None, cert_reqs=ssl.CERT_NONE, certfile=None, server_side=False, ssl_version=ssl.PROTOCOL_TLS)
data= '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Login xmlns="http://videoos.net/2/XProtectCSServerCommand"><instanceId>' + str(v) + '</instanceId><currentToken></currentToken></Login></soap:Body></soap:Envelope>'
data_len = len(data)
data_len = str(data_len)
s.sendall("POST /ManagementServer/ServerCommandService.svc HTTP/1.1\r\nHost: server-ip\r\nContent-Type: text/xml; charset=utf-8\r\nAuthorization: Basic (base64 of '[BASIC]\username:password')\r\nContent-Length: "+data_len+"\r\nSOAPAction: http://videoos.net/2/XProtectCSServerCommand/IServerCommandService/Login\r\nConnection: close\r\n\r\n" + data)
while True:
new = s.recv(4096)
if not new:
s.close()
break
print(new)
我正在使用基本身份验证。
我想连接到里程碑 sdk (MIPSDK) 的管理服务器并获取 MIPSDK 的 imageServer 的令牌。我正在使用套接字,但不知道该怎么做。 这是我到目前为止所做的
import ssl
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.x.xx', 443))
s = ssl.wrap_socket(s, keyfile=None, cert_reqs=ssl.CERT_NONE, certfile=None, server_side=False, ssl_version=ssl.PROTOCOL_TLS)
s.settimeout(10);
s.sendall("POST /ManagementServer/ServerCommandService.svc HTTP/1.1\r\nHost: 192.168.xx.xx\r\nAuthorization:Basic\ xxxxxx\r\nContent-Length: 2048\r\n\r\n")
new = s.recv(4096)
print new
甚至可以从 python 客户端登录到管理服务器吗? DotNet 中有内置 classes/functionalities,但我无法找到任何 python 实现。
环顾四周后,我终于设法从 milestone imageServer 获得了令牌。
import ssl
import socket
import uuid
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('server-ip', 443))
v = uuid.uuid4()
s = ssl.wrap_socket(s, keyfile=None, cert_reqs=ssl.CERT_NONE, certfile=None, server_side=False, ssl_version=ssl.PROTOCOL_TLS)
data= '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Login xmlns="http://videoos.net/2/XProtectCSServerCommand"><instanceId>' + str(v) + '</instanceId><currentToken></currentToken></Login></soap:Body></soap:Envelope>'
data_len = len(data)
data_len = str(data_len)
s.sendall("POST /ManagementServer/ServerCommandService.svc HTTP/1.1\r\nHost: server-ip\r\nContent-Type: text/xml; charset=utf-8\r\nAuthorization: Basic (base64 of '[BASIC]\username:password')\r\nContent-Length: "+data_len+"\r\nSOAPAction: http://videoos.net/2/XProtectCSServerCommand/IServerCommandService/Login\r\nConnection: close\r\n\r\n" + data)
while True:
new = s.recv(4096)
if not new:
s.close()
break
print(new)
我正在使用基本身份验证。