Restful Services Integration
This chapter describes how to connect with restful services from Trillo. It is done using Trillo functions. Trillo provides a distributed cache to store access token in a clustering environment.
Last updated
This chapter describes how to connect with restful services from Trillo. It is done using Trillo functions. Trillo provides a distributed cache to store access token in a clustering environment.
Last updated
The concept is simple:
Store API credentials in the secret manager (so only authorized people can see them). On GCP, it uses Google Cloud secret manager.
Using credentials, retrieve access token. To support, the use of the same token in a clustering environment, store it in a distributed memory cache provided by Trillo Workbench.
Use Trillo funciton to write connector logic using HTTP APIs.
Store client credentials in the secret manager (preferably).
Store any other API related configuration as domain meta data.
Write function using MetaApi and TokenApi (see below).
Use the following HTTPApi method to communicate with the service.
Test in IDE or on the cloud by copying the code using Trillo Workbench UI.
The following APIs are available using Trillo SDK.
It assumes that an admin (authorized person) has given name to each value and made entry in the GCP secret manager.
Using the name of a secret you can retrieve its value at runtime using the following API.
You normally obtain access token once and use it several times. In a clustering environment, one node may fetch the token, but code running on another node uses it due to a later request. The access token should be stored in a distributed memory cache so it is available to processes running on different nodes.
Assuming you receive OAuth2 compliant access token as a JSON object, it can be converted to a Java class OAuth2Token as follows.
You can then add it to Trillo Workbench distributed cache using the following API call.
You can later retrieve it from the cache using the following API call.
You can remove the token from the cache as follows.
The following method of OAuth2Token can be used to check if the token has expired.