Getting StartedPOST /v1/auth/
Exchange the client credentials for an access token, and build the request headers every other
recipe uses.
import json
import requests
BASE = "https://api.securithings.com"
ORGANIZATION = "<organization>"
CLIENT_ID = "<client-id>"
CLIENT_SECRET = "<client-secret>"
response = requests.post(
f"{BASE}/v1/auth/{ORGANIZATION}",
auth=(CLIENT_ID, CLIENT_SECRET),
)
response.raise_for_status()
body = response.json()
access_token = body["access_token"]
headers = {"Authorization": f"Bearer {access_token}"}
result = {
"access_token": access_token,
"expires_in": body["expires_in"],
}
print(json.dumps(result, indent=2))
Output
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"expires_in": 3600
}