Zoho Deluge: Setup an API Connection for InvokeURL

What?
This is slightly different to my article Zoho Deluge: Get Refresh/Access Token API v2 (Zoho to Zoho service) and different to my Zoho CRM: APIv2 using PHP & cURL (3rd-Party to Zoho), in that this details how to setup a connection to use in an invoke URL statement. Specifically for Zoho Books, Subscriptions or Inventory.

Why?
Setting up a connection avoids the hassle of having to generate access/refresh tokens using OAuth2.0. Usually used with an invokeUrl:
response = invokeUrl
[ 
	url: "https://books.zoho.com/api/v3/estimates?organization_id=12346789" 
	type: GET
	connection: "joelconnector" 
];

How?
So in the following example, we are going to setup a connection in Zoho Books on an EU datacenter:
  1. First determine what datacenter your client is using
  2. Register the App
  3. Setup the Connector

How do I determine what datacenter to use?
To find out which datacenter your client/customer is using in Zoho, check the domain and specifically the top-level-domain (TLD) part. For example, if it says zoho.com, then this means the US datacenter. If it says zoho.eu, then this is the EU datacenter. If it says zoho.in, then this is the India datacenter.

View the attached if this is still confusing. The following screenshot is of a client's Zoho Books instance opened in a browser. the circled part is the domain of the Zoho app we are accessing:
Setup Connection: Determine DataCenter from Website Address

Here is a list of the datacenters that I know of:
  • AU = Australia (zoho.com.au)
  • CN = China (zoho.com.cn)
  • EU = Europe (zoho.eu)
  • IN = India (zoho.in)
  • US = United States (zoho.com)

Registering the App
You need to do this so as to tell which Zoho system for which organization you are connecting to. If you get this wrong, you may access the wrong system (such as your own rather than the clients) or you may not access anything at all.
  1. Open a new browser window (preferably using the Google Chrome profile you have for the customer) Logged in to Zoho as an Administrator of the system to access.
  2. Browse to the Zoho Developer Console at the appropriate link based on the clients datacenter:
  3. If this is your first app, then click on "Get Started" and select "Server-based Applications" by clicking on "Create Now" on the appropriate box.
  4. If this is not your first app, just select "Server-based Applications", then on the plus icon to add new client.
  5. Fill in the new form to Create New Client:
    1. Client Name: put something descriptive so it is easy to identify if the client has 3rd-parties adding clients. eg. "JoelLipman_BooksConnector".
    2. Homepage URL: put our corporate website URL, this is for developers who need to query what this app belongs to or does. eg. "https://www.joellipman.com/"
    3. Authorized Redirect URIs: for this put in one of the following options, again, based on the clients datacenter:
    4. Click on "Create"
    5. You will be issued a Client ID and Client Secret, make a note of these or leave this window to copy&paste into the next step.
      Setup Connector: Copy Client ID and Client Secret

    Setting up the Oauth Connector
    So return to your Zoho Books instance (or Subscriptions, Inventory, app you were making the connection):
    1. From within books (or inventory, subscriptions as these are simillar), go to edit a custom function and click on the "Connections" link to the top right of a function:
      Setup Connector: The Connections button in Zoho Books
    2. If this is your first connection, simply click on the "Go To Connections" button
    3. Select "Custom Service" and complete the form:
      1. Service Name: Enter a descriptive name that can help you find it amongst many connections. eg. "the Joel Lipman App".
      2. Service LinkName: Not sure what this is used for but I enter the same name in lowercase and replacing special characters with an underscore. eg. "the_joel_lipman_app"
      3. Authentication Type: set this to "oauth2"
      4. Param Type: set this to "Header"
      5. Grant Type: set this to "Authorization Code"
      6. Client ID: Copy & paste from the previous step this value into this field.
      7. Client Secret: Copy & paste from the previous step this value into this field.
      8. Authorize URL: Enter the Zoho authentication URL based on the client's datacenter:
        • US datacenter: https://accounts.zoho.com/oauth/v2/auth
        • EU datacenter: https://accounts.zoho.eu/oauth/v2/auth
        • CN datacenter: https://accounts.zoho.com.cn/oauth/v2/auth
        • IN datacenter: https://accounts.zoho.in/oauth/v2/auth
      9. Access Token URL: Enter the Zoho token URL based on the client's datacenter:
        • US datacenter: https://accounts.zoho.com/oauth/v2/token
        • EU datacenter: https://accounts.zoho.eu/oauth/v2/token
        • CN datacenter: https://accounts.zoho.com.cn/oauth/v2/token
        • IN datacenter: https://accounts.zoho.in/oauth/v2/token
      10. Refresh Token URL: Enter the Zoho token URL based on the client's datacenter:
        • US datacenter: https://accounts.zoho.com/oauth/v2/token
        • EU datacenter: https://accounts.zoho.eu/oauth/v2/token
        • CN datacenter: https://accounts.zoho.com.cn/oauth/v2/token
        • IN datacenter: https://accounts.zoho.in/oauth/v2/token
      11. Connection Name: Put a descriptive name
      12. Connection LinkName: Put the link name that we will use in code later (preferably in lowercase as it will lowercase it anyway)
      13. Scope: Enter each scope you need and click on the plus icon to add each one.
      14. Keep "Use credentials of login user" ticked.
      15. You should have something like the following:
        Setup Connection: Form Overview
      16. Click on "Create and Connect"
    4. You will get a popup confirming what this app will access and you should click on "Accept":
      Setup Connection: Accept App Permissions
    5. A quick popup will appear to say connected. Done!

    Now you can use this in your custom function with the invokeURL without the need for a header parameter:
    response = invokeUrl
    [ 
    	url: "https://books.zoho.com/api/v3/estimates?organization_id=12346789" 
    	type: GET
    	connection: "joelconnector" 
    ];
    

    Additional
    I'd always recommend locking down your app privileges by checking the scope(s) you have allowed it to have.... However in those times of debugging/testing when you can't seem to access that bit of information Zoho is reluctantly letting you have (such as comment information for estimates/sales orders/invoices). There are some quietly documented scopes granting absolute access:
    • ZohoBooks.fullaccess.all
    • ZohoInventory.FullAccess.all
    • ZohoSubscriptions.fullaccess.all

    Other Links

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.