Ottenere il token

L'API usa OAuth2 con token JWT. Il token si ottiene autenticandosi con le credenziali dell'account admin dell'Integration Company:

curl -X POST \
  -H 'Accept: application/json' \
  'https://<client_id>:<client_secret>@api.ipdoor.com/oauth/token' \
  -d 'grant_type=password&username=<email_admin>&password=<pass_admin>'

La risposta contiene il token da usare nelle chiamate successive:

{
  "access_token": "eyJhbG...",
  "token_type": "bearer",
  "refresh_token": "eyJhbG...",
  "scope": "read write",
  "type": "USER",
  "user_id": "<id_admin>",
  "username": "<email_admin>"
}

Il valore di access_token va passato in ogni chiamata nell'header Authorization, preceduto da Bearer:

curl -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer eyJhbG...' \
  'https://api.ipdoor.com/api/v2/users/me'

Il token ha una validità di 24 ore: scaduto, va rifatto il login (oppure usato il refresh_token). GET /api/v2/users/me è anche il modo più rapido per leggere l'id dell'utente admin, che serve in alcune chiamate.