Connectors

Catalyst Connectors manage the access token, by refreshing it automatically on expiry. In the background, it will be using the Catalyst Cache for its implementation. A connector is illustrated with the following code block.

Ensure the following packages are imported:

Copiedimport org.json.simple.JSONObject;
import com.zc.auth.connectors.ZCConnection;
import com.zc.auth.connectors.ZCConnector;
CopiedJSONObject authJson = new JSONObject();
// The json object holds the client id, client secret, refresh token and refresh url
authJson.put("client_id","{client_id}");
authJson.put("client_secret","{client_secret}");
authJson.put("auth_url","{auth_url}");
authJson.put("refresh_url","{refresh_url}");
//If referesh token is not provided, then code should be provided to generate the refresh token.
authJson.put("refresh_token","{refresh_token}"); 
JSONObject connectorJson = new JSONObject();
connectorJson.put("CRMConnector",authJson);
// It can have multiple service connector information
ZCConnection conn = ZCConnection.getInstance(connectorJson);
ZCConnector crmConnector = conn.getConnector("CRMConnector");
// Gets the access Token
String accessToken = crmConnector.getAccessToken();