How does the RTSP protocol TSINGSEE Qingxi video platform EasyNVR obtain the login authentication through the GET method

As the security restrictions of browsers are getting higher and higher, especially when designing to cross-domain data calls, the restrictions are becoming stricter. As the capability layer, EasyNVR needs to call the interface, so there are often many inconveniences in the call interface for token verification.

dc03aef999ec20443dd5601402032bfc.png

In response to these problems, EasyNVR is also compatible with the get method of token verification after the new version 4.1.0 (including version 4.1.0). That is, the interface that needs to use the token value obtained by login in the subsequent can be passed through the interface by the method of get value to achieve the interface call.

Front-end code implementation:

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>EasyNVR</title>
</head>
<body>
	<h5>DEMO</h5>
	<input type="button" value="登录" id="login" />
	<input type="button" value="退出" id="loginout" />
	<input type="button" value="获取通道" id="modify" />  
	<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
    <h6>返回数据展示<h6>
    <input type="text" name="userName" style="height: 400px;width: 1000px;" id="text">

</body>
<script type="text/javascript">
var token
	$(function () {
		$("#login").click(function () { //登录
			$.ajax({
				type: "GET",
				Url:"http://127.0.0.1:10800/api/v1/login?username=easynvr&&password=ec6206d95f5772323792621ad25ffedf",	
			success: function(data) {
					token=data.EasyDarwin.Body.Token
					console.log(data.EasyDarwin.Body.Token);	
				}
			});
		});
		$("#loginout").click(function () { //退出
			$.ajax({
                type:"Get",
                url:"http://127.0.0.1:10800/api/v1/logout",
                success: function (data) {
					console.log(data);
				}
            })
		});  
        $("#modify").click(function () { 
			$.ajax({
                type:"Get",
           url:"http://127.0.0.1:10800/api/v1/getchannelsconfig?token="+token,
                success: function (data) {
					console.log(data);
				}
            })
		});     
})	
</script>
 </html>

Example:

DEMO

 

Guess you like

Origin blog.csdn.net/EasyNVR/article/details/109636773