Oauth2 Token not getting refreshed. Throwing 401 after expiry

Oauth 2 Token not getting refreshed from version 220. This works perfectly in v219.1. Is there anything that was changed in the recent builds. Example : Gmail trigger, Hubspot trigger (On Message Received Event)

Error : 401 after token expiry in 1 hr (Please check the credentials)

workflow

{
“meta”: {
“instanceId”: “65c9d67506f393f609b8a2a7eb3b976af48e42de1d69b600ef264f733041110c”
},
“nodes”: [
{
“parameters”: {
“pollTimes”: {
“item”: [
{
“mode”: “everyMinute”
}
]
},
“simple”: false,
“filters”: {},
“options”: {}
},
“typeVersion”: 1,
“name”: “Invoice AP Inbox”,
“id”: “e4610e4d-9ef8-4f6e-88cd-65e4427536cb”,
“position”: [
-800,
380
],
“type”: “n8n-nodes-base.gmailTrigger”,
“credentials”: {
“gmailOAuth2”: {
“id”: “243”,
“name”: “Gmail account 2”
}
}
},
{
“parameters”: {
“jsCode”: “return $("Numero - Document AI Processor").all()[0].json.line_items”
},
“typeVersion”: 1,
“name”: “Get Line Items”,
“id”: “893f023b-50dd-4563-8f75-cb63ff797042”,
“position”: [
340,
380
],
“type”: “n8n-nodes-base.code”
},
{
“parameters”: {
“resource”: “items”,
“itemName”: “={{ $json["description"] }}”
},
“typeVersion”: 1,
“name”: “ZohoBooks Get Items”,
“id”: “3006a2dc-b1c9-4616-8dd9-c28955e13c3d”,
“position”: [
500,
380
],
“type”: “CUSTOM.zohobooks”,
“credentials”: {
“zohoBooksOAuth2Api”: {
“id”: “245”,
“name”: “Zoho Books Account - [60019914854]”
}
}
},
{
“parameters”: {
“jsCode”: “const arr = []\nconst finalObj = {}\nconst originalLineItems = $("Get Line Items").all();\nfor (let idx=0; idx < $input.all().length; idx++) {\n const item = $input.all()[idx];\n const originalItem = originalLineItems[idx];\n const obj = {};\n obj["item_id"] = item.json["item_id"];\n obj["rate"] = parseFloat(originalItem.json.amount.replaceAll(",",""))\n arr.push(obj)\n}\nfinalObj["line_items"] = arr;\n\nreturn [finalObj];”
},
“typeVersion”: 1,
“name”: “Construct Line Items”,
“id”: “3c34e287-1809-484d-bec8-490532381757”,
“position”: [
680,
380
],
“type”: “n8n-nodes-base.code”
},
{
“parameters”: {
“jsCode”: “const requestBody = {};\nconst processedResponses = $("Numero - Document AI Processor").all();\nconst processedResponse = processedResponses[0].json;\nconst constructedLineItems = $("Construct Line Items").all();\nconst companyDetailsList = $("ZohoBooks - Get Company").all();\nrequestBody["bill_number"] = processedResponse["invoice_id"];\nrequestBody["vendor_id"] = companyDetailsList[0].json["contact_id"];\nrequestBody["line_items"] = constructedLineItems[0].json["line_items"];\nreturn [requestBody];”
},
“typeVersion”: 1,
“name”: “Construct Full Payload”,
“id”: “27554b52-7ea4-404e-8869-0ccd4cb9f3ef”,
“position”: [
860,
380
],
“type”: “n8n-nodes-base.code”
},
{
“parameters”: {
“resource”: “bills”
},
“typeVersion”: 1,
“name”: “ZohoBooks - Create Bill”,
“id”: “418a8fd8-c6b6-42ff-a366-e18586732acc”,
“position”: [
1060,
380
],
“type”: “CUSTOM.zohobooks”,
“credentials”: {
“zohoBooksOAuth2Api”: {
“id”: “245”,
“name”: “Zoho Books Account - [60019914854]”
}
}
},
{
“parameters”: {
“operation”: “markAsRead”,
“messageId”: “={{ $json["id"] }}”
},
“typeVersion”: 2,
“name”: “Mark as Read”,
“id”: “37feb7d9-39bc-4a87-810b-2770a9ba4baf”,
“position”: [
-240,
660
],
“type”: “n8n-nodes-base.gmail”,
“credentials”: {
“gmailOAuth2”: {
“id”: “243”,
“name”: “Gmail account 2”
}
}
},
{
“parameters”: {
“operation”: “get”,
“messageId”: “={{$node["Invoice AP Inbox"].json["id"]}}”,
“simple”: false,
“options”: {
“downloadAttachments”: true
}
},
“typeVersion”: 2,
“name”: “Get Attachment”,
“id”: “071af3f8-d1fb-4e9e-98ac-7f460771e7fc”,
“position”: [
-580,
380
],
“type”: “n8n-nodes-base.gmail”,
“credentials”: {
“gmailOAuth2”: {
“id”: “243”,
“name”: “Gmail account 2”
}
}
},
{
“parameters”: {
“jsCode”: “const value = $input.all();\nconst mainObj = value[0];\nconst binaryObj = mainObj.binary;\nreturn binaryObj;”
},
“typeVersion”: 1,
“name”: “Fetch Attachment”,
“id”: “0ad24b9d-be07-4f0b-a9b7-91b810fb9a7c”,
“position”: [
-360,
380
],
“type”: “n8n-nodes-base.code”
},
{
“parameters”: {
“companyName”: “={{ $json.supplier_name }}”
},
“typeVersion”: 1,
“name”: “ZohoBooks - Get Company”,
“id”: “80afeeb2-9953-42b9-a262-7d3607aa6c2e”,
“position”: [
100,
380
],
“type”: “CUSTOM.zohobooks”,
“credentials”: {
“zohoBooksOAuth2Api”: {
“id”: “245”,
“name”: “Zoho Books Account - [60019914854]”
}
}
},
{
“parameters”: {
“resource”: “docparser”,
“operation”: “invoice”,
“pdfString”: “={{ $json.attachment_0.data }}”
},
“typeVersion”: 1,
“name”: “Numero - Document AI Processor”,
“id”: “b1f5ebb0-8ade-4a3d-9cbd-f117e014fbc7”,
“position”: [
-140,
380
],
“type”: “CUSTOM.numero”
}
],
“connections”: {
“Invoice AP Inbox”: {
“main”: [
[
{
“node”: “Get Attachment”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get Line Items”: {
“main”: [
[
{
“node”: “ZohoBooks Get Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“ZohoBooks Get Items”: {
“main”: [
[
{
“node”: “Construct Line Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Construct Line Items”: {
“main”: [
[
{
“node”: “Construct Full Payload”,
“type”: “main”,
“index”: 0
}
]
]
},
“Construct Full Payload”: {
“main”: [
[
{
“node”: “ZohoBooks - Create Bill”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get Attachment”: {
“main”: [
[
{
“node”: “Mark as Read”,
“type”: “main”,
“index”: 0
},
{
“node”: “Fetch Attachment”,
“type”: “main”,
“index”: 0
}
]
]
},
“Fetch Attachment”: {
“main”: [
[
{
“node”: “Numero - Document AI Processor”,
“type”: “main”,
“index”: 0
}
]
]
},
“ZohoBooks - Get Company”: {
“main”: [
[
{
“node”: “Get Line Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Numero - Document AI Processor”: {
“main”: [
[
{
“node”: “ZohoBooks - Get Company”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}

Share the output returned by the last node

Information on your n8n setup

  • **n8n version: v220 **
  • **Database you’re using (default: SQLite): Postgres **
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker Compose

Hey @Mahesh_Thiru,

Can you try formatting your message correctly? Looking at the json you have posted are you using a custom node?

Hi @Jon,

Yes. I am using a custom node. Sure I will format it now. Sorry…
It works in v219.1 but fails from v220. Not sure why. Also, I may be wrong by raising this. I am sure that a error like this will not go missing. Please let me know if I am doing something wrong.

Regards,
Mahesh

Hey @Mahesh_Thiru,

Is this only an issue for the Zoho Books node?

@Jon ,

I am facing this issue with Gmail trigger node, Hubspot node. These are the two nodes that I use now.

Regards,
Mahesh

Hey @Mahesh_Thiru,

Does the gmail trigger and hubspot nodes both expire after an hour as well or is there more time?

@Jon ,

Not sure about the timing of expiry of hubspot. I believe its half an hour going by the expiry time. But for Gmail its 1 hour.

Regards
Mahesh

That is odd it sounds like something is not set up correctly, For now I would go back to 219.1 just to confirm it works or try using 221.

I have not seen an issue with my local workflows that use GMail so there could be something else I am missing with your setup.

@Jon i can confirm the same issue is happening for us as well. We were using the Google Translate node where the token expires after 1 Hour. We had to downgrade to V 219. Downgrading seems to fix this issue.

Hey @mohamedazher,

Welcome to the community :raised_hands:

What version did you see the issue on? This should be working now on newer versions.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.