Convert Authtokens to OAuth in Existing Deluge Scripts
If your Deluge script uses Authtokens to invoke any Zoho APIs, you will need to change this script from Authtoken to OAuth-based authentication. This can be done with ease using Deluge's Connections. Learn how to set up and create new Connections.
Once you've created a Connection, simply remove the Authtoken details from your existing script and replace it with Connections instead. Here's how:
Existing Deluge script:
Example 1: An InvokeURL task with Authtoken-based authentication
invoiceID = invoice.get("invoice_id");
invoicedate = invoice.get("date").toDate();
organizationID = organization.get("organization_id");
authtoken = "XXXXXXXXXXXXXXX";
invDetails = invokeurl
[
url :"https://www.zohoapis.com/invoice/v3/invoices/" + invoiceID + "?organization_id=" + organizationID + "&authtoken="+ authtoken
type :GET
];
Existing Deluge script:
Example 2: A GetURL/PostURL task with Authtoken-based authentication
invoiceID = invoice.get("invoice_id");
invoicedate = invoice.get("date").toDate();
organizationID = organization.get("organization_id");
authtoken = "XXXXXXXXXXXXX";
result = getUrl("https://www.zohoapis.com/invoice/v3/invoices/" + invoiceID + "?organization_id=" + organizationID + "&authtoken=" + authtoken);
Revised Deluge script with OAuth-based authentication:
Here, invoiceconnection is the name of the Connection in Deluge, and you will have to replace it with your own Connection's name.
Once these changes have been made, your Deluge script will start using OAuth 2.0 for authentication with Zoho APIs.
invoiceID = invoice.get("invoice_id");
invoicedate = invoice.get("date").toDate();
organizationID = organization.get("organization_id");
invDetails = invokeurl
[
url :"https://www.zohoapis.com/invoice/v3/invoices/" + invoiceID + "?organization_id=" + organizationID
type :GET
connection : "invoiceconnection"
];
Adding Connection Details to Integration Tasks
To ensure that the integration tasks in your Deluge scripts use OAuth 2.0, you must add Connection details to them.
Note: You need not make these changes to integration tasks which were created before November 2020, as Deluge will take care of this automatically.
The example on the right is of an existing integration task, to which we've added Connection details.
Here, invoiceconnection is the name of the Connection.
invoiceID = invoice.get("invoice_id");
organizationID = organization.get("organization_id");
invDetails = zoho.invoice.getRecordsByID("invoices", organizationID, invoiceID,"invoiceconnection");
info invDetails;