How to connect to Zoho using their custom OAuth2

Seems like Zoho team is creative and they use different header for OAuth 2.

Similar issue to this:

The request is:

curl "https://sheet.zoho.com/api/v2/create"
 -H 'Authorization: Zoho-oauthtoken '$oauthtoken
 -d 'method=workbook.create&workbook_name=Sheet1'
 -X POST

How do I setup Oauth credentials in n8n? When I create generic OAuth 2 credentials I get an error:

Full message

401 - "{\"error_message\":\"Valid [OAUTHTOKEN] is required for processing the request.\",\"error_code\":2401}"
1 Like

@vladaman Hello,

So, i’m guessing your using the zoho node? and not http request,

If you can’t change it within the zoho node, you maybe better using the http request node, which then you can specify Zoho-oauthtoken etc, like this

You can do like this. Hope this helps.

Best regards,

Samuel

Hi @King_Samuel_David thanks for your suggestion. I am not using Zoho Node, since that one supports just Zoho CRM Scope (we need different scopes for other services).

Problem with manual HTTP request is that the token needs renewal and we need Zoho Auth to refresh the token automatically. Your solution would work with static token. for an hour or so.

Hey @vladaman,

I’m thinking, maybe you can have some logic which checks the token first maybe? if it expired, request new, and continue?

https://www.zoho.com/books/api/v3/oauth/#overview:~:text=Step%202%3A%20Generating%20Grant%20Token

Maybe use the refresh endpoint? OAuth | Zoho Books | API Documentation

Step 4: Generate Access Token From Refresh Token

Access Tokens have limited validity. In most general cases the access tokens expire in one hour. Until then, the access token has unlimited usage. Once it expires, your app will have to use the refresh token to request for a new access token. Redirect to the following POST URL with the given params to get a new access token

https://accounts.zoho.com/oauth/v2/token?

Parameter Description
refresh_token REFRESH TOKEN which is obtained in the above step
client_id Client ID obtained during Client Registration
client_secret Client secret obtained during Client Registration
redirect_uri This param should be same redirect url mentioned while registering Client
grant_type refresh_token

I guess you may have tried this.

Best regards,

Samuel

Hi, just want to shed light on this. So you won’t be able to get it work with oauth2 in n8n. I have tried the Zoho Mail api which had the same issue. The output of the Zoho API isn’t what n8n expects so after 1 hour it stops no matter what.

A work around that would work is to use multiple nodes to refresh the token and then save it.

1 Like

Thanks guys! I could not get it to work so I created new n8n node with Zoho compatible OAuth

I plan to add support for other services. Currently tested on Zoho Sheets and Zoho Billing

1 Like

Thank you for sharing. There were some other other which have had the same issue with Zoho. Good to know there is a workaround in the meanwhile.