Authorization
API Key
The API Key in the RedBook Direct API identifies the user (similar to a username and password) as the holder of a valid RedBook Direct API account with access to certain APIs configured at the time of account creation.
API Keys (one or multiple) are issued by the RedBook support team. The number of API Keys that can be generated per account is controlled by RedBook.
Access Token
The API Key is used to generate a JWT token called the Access Token. For security purposes, the Access Token limits access to the API for a specified period, after which it expires and new tokens need to be generated. The Access Token is valid for 1 hour.
This JWT token is used as the Bearer token in all API calls.
Refresh Token
The Refresh Token is a JWT token generated at the same time as the Access Token. Its purpose is to generate a new pair of Access and Refresh tokens when the current Access Token expires. The Refresh Token is valid for 7 days.
How the tokens fit together
The flow of a request through the API using API Keys and tokens is:
- Store your API Key. Once issued it is non-recoverable: if lost, a new one must be issued by RedBook.
- Use the API Key to generate an Access Token. The API Key is used to generate an Access Token, which in turn is used to access the endpoints authorised as part of account creation. The Access Token is valid for one hour, during which time it can be used to call the endpoints.
- Use the Access Token to call an endpoint. The Access Token is sent as a Bearer token in each request.
- Use the Refresh Token to get a new pair of tokens when the Access Token expires. When the Access Token expires, the Refresh Token (along with the Access Token) can be used to generate a new pair of Access and Refresh tokens. The Refresh Token is valid for 7 days.
See Generate Tokens for the exact steps and examples.