Hik_isToken.py 545 B

12345678910111213141516171819
  1. import requests
  2. from Utils.HikAccessToken import hik_access_token
  3. def hik_is_token(hik_accesstoken,client_id,client_secret):
  4. response = requests.get(
  5. url="https://api2.hik-cloud.com/api/v1/open/basic/persons/list?access_token=%s&pageNo=1&pageSize=1" % (
  6. hik_accesstoken)
  7. )
  8. response = response.json()
  9. if response["code"] == 401:
  10. print("hik token失效,重新获取token")
  11. hik_accesstoken = hik_access_token(client_id,client_secret)
  12. return hik_accesstoken
  13. return hik_accesstoken