Hello. I’m trying to create an Oauth2 connection (http node) for Zoho Inventory but right after the permissions page, it goes to 404 error. On zoho, a server-based client credential was created & details from there were added but the connection was not successful.
The url does give the one-time code (valid for 60seconds) with the url of the request. I’m thinking, n8n should be using that to get the access token (valid for 1H) & the refresh token–with new access token generated once a request fails. Is this not the case? Do I have to do a manual loop?
Hi @jay, this is an error coming from Zoho and I am not familiar with their authentication unfortunately. Do you have any link where they explain how their tokens are renewed or how to get a long lived token?
That makes sense. I had tried oauth2 with integromat & over there, the issue was that it wasn’t renewing/regenerating access token with the given refresh token but the connection was successful (for 1H).
Thanks for the link, I’ll play around with this when I find some time.
In the meantime, could you try setting the Authentication field value to Body rather than Header? That’s what the built-in Zoho credentials do and I wonder if that might already make a difference.
In the documentation, it mentions the use of header but I just tried body & it still results in 404.
Edit: Is it possible to overwrite the initial auth uri params? So I could get the access_token & refresh_token (postman) and then pass them as params through n8n.
The authentication definitely lasts longer than 60 seconds, but I am not sure if the renewal after each hour works yet. I have added a Cron node to my example workflow running every 15 minutes and will check later today if it’s still working.
So the renewal seems to work okay using this approach. However, one thing that came to mind here was your use of the desktop app @jay. Do you have it closed for longer periods of time by any chance (for example because it’s running on an actual desktop machine that’s turned off outside of working hours)?
If so the token renewal might fail (because the refresh token no longer works when your instance comes back online. You might want to consider hosting n8n on a server or use n8n.cloud rather than your desktop to avoid hitting that problem.
I wanted to ask a follow-up question related to this one. I’m fighting the same issue but with Zoho CRM. In my case I have followed the above advice. I’m using the Multi-DC option in Zoho’s API Console and have configured my generic oauth2 credential. I also set up a 15-minute scheduled workflow, and it works ok for the first hour then starts responding with errors afterwards. See example output below.
I’ve parsed out the access token and refresh token values using the nodes as follows. In the condition where there is an invalid token, how can I use the refresh token to reauthenticate and proceed through the workflow?
Hi @hndmn, if you manually refresh an access token and thus circumvent the n8n OAuth2 logic, you’d have to use it in an Authorization header as described here:
Access Token: An end-user authorized key that lets the client access protected resources from the resource server. The client can make API calls using this access token for up to an hour after the creation of the access token.
So you’d want to store this updated token (along with your refresh token), then read it whenever needed and attach it to your HTTP Request in the aforementioned header. Like so I think based on the Zoho docs:
Thanks for this @MutedJam. My preference would be to utilize the n8n OAuth2 logic, but for whatever reason Zoho tokens are not refreshing and expire after an hour, so I need this as a workaround to keep workflows running without any interaction.