OKM API Tokens
API tokens are used in the exchanges between the OKM Service and OKMs, to control which OKMs are authorized to query the service. The purpose of the token is to indicate that an OKM is authorized to make requests to an OKM Service instance.
These are separate from the JWT access tokens used by implementers. See JWT Authentication for the resource endpoints.
Endpoints using this mechanism
/config/{serial_number}/audit/{serial_number}
An OKM that is unknown to the service, or whose token is missing or invalid, will not be served by these endpoints.
Exchange Flow Summary
This is how the initial token attribution flow happens, in short. At this time, there is no UI implemented for a person to manually “allocate” the token for an OKM. So for now, the token is flagged as claimed when it’s first attributed to the OKM.
- OKM calls the OKM service.
- The service looks into its DB for the OKM.
- OKM not found.
- OKM is added to service-application (via portal most likely).
- OKM create request is sent to OKM Service.
- OKM service generates API Token for this OKM.
- Token claimed flag is false.
- User adds tags to OKM in service-application:
- this triggers the generation of an ACL;
- ACL create request is sent to OKM service.
- OKM connects again.
- Service looks in DB and finds OKM has an ACL and has an unclaimed token.
- Service returns
msg_Token_eresponse to OKM with token. - OKM connects again with an
Authorization: Bearer <token>in its request header. - Service compares bearer token with token in database.
- If token is not the correct one, a 401 - Unauthorized is returned.
- If token is good, service marks token as claimed and processing continues down the stack.
This OKM can now make requests to this OKM service instance. All requests from now on will require the token. If the token is not present or doesn’t match what’s stored in the server, the request is denied.
Note A firmware update will erase the token from the OKM memory. Once the OKM reconnects after a firmware update, a new API access token needs to be obtained.
Managing a token
A token is issued per OKM and is tracked as claimed or unclaimed. Two endpoints on the OKM resource manage its lifecycle:
- Refresh the API Access Token of an OKM issues a new token and marks it unclaimed.
- Clear the API Access Token of an OKM deletes the token and marks it unclaimed.
Both are useful when doing a factory reset of an OKM without deleting it from the system, and then connecting it again to the same system.