Access tokens are security credentials used by Genetec ClearID™'s API to authenticate users and authorize access for a set amount of time. With an access token, users' information is protected through encryption for each renewed call to the API.
This section assumes that you have retrieved an access token following the steps described in the Authentication article.
This access token is a bearer token that must be passed to any API request. The bearer token has an expiration, and the authentication flow described in the previous article must be done before the bearer token expires.
As explained before the Secure Token Service (STS) return this JSON payload after successful authentication.
{
"access_token": "eyJhbGciOiJSUzUxMiIsImtpZCI6IjIwMTgtMDEtMjYtaWFtcy1zaWduaW5nLWNyZWRlbnRpYWwiLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NDAwMzAxMjIsImV4cCI6MTY0MDAzMzcyMiwiaXNzIjoiaHR0cHM6Ly9zdHMtZGVtby5jbGVhcmlkLmlvIiwiY2xpZW50X2lkIjoiNjYyNTIyMWYtNGU2Ni00YmM4LTgzMDUtY2I4Y2JkODdiMjFmOmNsZWFyaWRkZW1vcyIsInN1YiI6IjY2MjUyMjFmLTRlNjYtNGJjOC04MzA1LWNiOGNiZDg3YjIxZiIsImF1dGhfdGltZSI6MTY0MDAzMDEyMiwiaWRwIjoibG9jYWwiLCJlbWFpbCI6IjY2MjUyMjFmLTRlNjYtNGJjOC04MzA1LWNiOGNiZDg3YjIxZiIsInJvbGUiOiJTZXJ2aWNlIiwiYWNjb3VudF9pZCI6ImNsZWFyaWRkZW1vcyIsImNsZWFyaWRkZW1vc19zdGF0ZSI6IkFjdGl2ZSIsImNsZWFyaWRkZW1vc19yb2xlIjoiYWRtaW4iLCJjbGVhcmlkZGVtb3NfaXNfZGVsZWdhdGUiOmZhbHNlLCJqdGkiOiIwMDUwRjA3ODk2MjRCNjlGREM5NjFEMTA4QkQ1RDc3MiIsImlhdCI6MTY0MDAzMDEyMiwic2NvcGUiOlsiaWFtcy1hbGwtcGVybWlzc2lvbnMtZGVsZWdhdGVkIiwiaWFtcy1hcGkiLCJpYW1zLXJvbGVzIiwib3BlbmlkIl0sImFtciI6WyJhc3NlcnRpb24iXX0.kO3QzR9KP8pQxu4juBtpotk1Gdfpt095f9V8Xx75tW3ZzjK5kNB8ZEjJKe34p8oe_YAou_6xFL_lrIc3L0X4I9qJaV-8RDnCzyw2hWw2Vh4TGpwNgfM-BE6e7NZzfvWsmByYCrQQqLNqtKyPirjNgYeO_dLtGdfSbHpBayV7r-nuurGNAc1I0Y5wtoo6vbuKtmXCYl59mD22kYE4o2ucVtt94P8RkoXPD6eTY0TNB-C1e1IQyGrMdlqcmff9TiUhrAIwSWmxr4E-4JlYdVqahZoLSg2ZnmpnSCAnQbCy568SEa-is9WbSO2LNhsKBW7_URa7rQ2-oDyC8h2pCDFXhg",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "iams-all-permissions-delegated iams-api iams-roles openid"
}
They are two important pieces of information in this response, the access_token
and the expiration.
The access_token
is temporary and should never be stored. It should only be kept in memory.
expires_in
is the number of seconds before the token becomes invalid. The maximum that ClearID allows is 3,600 seconds, or 1 hour. Make sure to request a new access token through the token endpoints before it expires.
Calling a REST API
Here is how we can call the Identity API to retrieve IDs that do not match any external ID.
The Identity Service REST API requires the accountid in almost every call.
GET /api/v2/accounts/{accountid}/identities
The AccountID is located in the JSON file downloaded from ClearID. See the Authentication for more details.
In every REST call, the Authorization header must be provided and contain the valid bearer token that the Token endpoint of the STS has returned.
Authorization: Bearer
GET /api/v2/accounts/cleariddemos/identities
host: https://identityservice-demo.clearid.io
accept: application/json
Authorization: Bearer eyJhbGciOiJSUzUxMiIsImtpZCI6IjIwMTgtMDEtMjYtaWFtcy1zaWduaW5nLWNyZWRlbnRpYWwiLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2NDAwMzY3MzgsImV4cCI6MTY0MDA0MDMzOCwiaXNzIjoiaHR0cHM6Ly9zdHMtZGVtby5jbGVhcmlkLmlvIiwiY2xpZW50X2lkIjoieW91ci1jbGllbnQtaWQiLCJzdWIiOiJqZG95b25AZ2VuZXRlYy5jb20iLCJhdXRoX3RpbWUiOjE2NDAwMzY3MzgsImlkcCI6Imd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NB: The complete list of all API endpoints is described here: API Endpoints
Expiration of an access token
The access_token
is in fact a JWT token. once decrypted (base64) it contains more information.
To find the exact expiration time of the access token, you must decode the bearer token and read the exp value, which is a Numericdate. In the bearer token provided above, the expiration is 1640033722, which is December 20, 2021 8:55:22 PM UTC.
To renew the access token, follow the same steps you did to initially retrieve it.
Decoded bearer token
{
"nbf": 1640030122,
"exp": 1640033722,
"iss": "https://sts-demo.clearid.io",
"client_id": "6625221f-4e66-4bc8-8305-cb8cbd87b21f:cleariddemos",
"sub": "6625221f-4e66-4bc8-8305-cb8cbd87b21f",
"auth_time": 1640030122,
"idp": "local",
"email": "6625221f-4e66-4bc8-8305-cb8cbd87b21f",
"role": "Service",
"account_id": "cleariddemos",
"cleariddemos_state": "Active",
"cleariddemos_role": "admin",
"cleariddemos_is_delegate": false,
"jti": "0050F0789624B69FDC961D108BD5D772",
"iat": 1640030122,
"scope": [
"iams-all-permissions-delegated",
"iams-api",
"iams-roles",
"openid"
],
"amr": [
"assertion"
]
}