A Catalyst Connector provides a seamless connection between Catalyst and an external Zoho service established through Zoho OAuth authentication. You can avail the use of a connector in your Catalyst application if your business logic includes the use of an external Zoho service’s API, such as a Zoho CRM or a Zoho WorkDrive API.

Catalyst handles the connection by storing the Access Token you generate in Zoho API console for a specific application in Catalyst Cache until its expiry. After it expires, the connector will automatically fetch a new Access Token using the Refresh Token and store it in the cache. Each time the Access Token expires, the connector automatically fetches and caches a new token in the background, relieving you from the efforts of constructing the logic to maintain an uninterrupted connection with the external Zoho service in your application’s business logic.

Note: Catalyst Connectors can only be used to maintain connections with an external Zoho service, and not any third-party services. This is because, the OAuth standards maintained across all Zoho services are uniform and compatible for Catalyst to implement the Connectors feature.

Before you configure the connector in your Java business logic as shown below, you will need to register a new client in the Zoho API console, and follow the steps to generate an Authorization Code and an Access Token for the first time. You can then configure the connector with the Refresh Token received, as well as other standard OAuth parameters such as the Client ID, Client Secret, Authentication URL, and Refresh URL that are required to refresh the Access Token automatically in a periodical manner. You can also incorporate your own logic in the connector based on your requirements.

  • The name you provide for each connector in your logic must be unique.
  • If you create a server-based application in the Zoho API console and you allow the access token to be created for different users within the same application, then you will need to provide a different and unique connector name for each user. This is because, when the same connector is used for different users in an application, the token will be overwritten on the same cache segment resulting in fetching the wrong user’s data from the external Zoho service.

The code below illustrates a Java connector.

Ensure the following packages are imported:

import org.json.simple.JSONObject; import com.zc.auth.connectors.ZCConnection; import com.zc.auth.connectors.ZCConnector;
JSONObject 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 refresh token is not provided, then you must provide the code to generate the refresh token authJson.put("refresh_token","{refresh_token}"); JSONObject connectorJson = new JSONObject(); connectorJson.put("CRMConnector",authJson); // You can create connectors for multiple Zoho services ZCConnection conn = ZCConnection.getInstance(connectorJson); ZCConnector crmConnector = conn.getConnector("CRMConnector"); // Fetches the AccessToken String accessToken = crmConnector.getAccessToken();

Last Updated 2024-03-22 17:59:45 +0530 +0530