Migration to OAuth using Connections (custom functions)
Lets take a look at a sample custom function created with authtoken authorization mechanism to update employee’s date of joining with today’s date.
Now let us see how we can replace authtoken authentication with OAuth using connections. The steps are as follows.
Note 1: The following steps are only valid for custom functions created within Zoho People and are not applicable to third-party applications. Once a connection is created, the same connection can be used across several custom functions. However, Multiple connections can be created if required too.
Step 1. Create a connection
- Navigate to Settings > Developer Space > Connections > Add Connection.
- Under Pick your Service, scroll down and select Zoho People
.
- Enter the connection details and click Create and Connect.
Connection Name: Name for the connection
ConnectionLinkName: Connection link name will be used in the code to use this connection.
Scope: Scope for the connection.
Based on the requirement (API to be called), select the respective scopes to be included for the connection.
- Click Authorize in the next screen.
- Click Proceed.
- Click Accept to create the connection.
- The connection will get created with the status “Connected”.
Step 2: Remove authtoken parameters in the existing custom function code and remove highlighted authtoken parameters
Step 3: Add connection parameter in invokeurl method and add connection parameter with the connection link name created in Step1.
Now the custom functions will use OAuth for authorization.
Note 2: For new custom function, Follow Step 1 and Step 3.