HikAccessToken.py 458 B

1234567891011121314
  1. import requests
  2. def hik_access_token(client_id,client_secret):
  3. data = {
  4. "client_id": client_id,
  5. "client_secret": client_secret,
  6. "grant_type": "client_credentials"
  7. }
  8. headers = {"content-type": "application/x-www-form-urlencoded"}
  9. response =requests.post(url="https://api2.hik-cloud.com/oauth/token",headers=headers,data=data)
  10. response_json = response.json()
  11. hik_access_token = response_json["access_token"]
  12. return hik_access_token