Problem with GMAIL flow v0.119.0

Hello,

I am having this error always with GMAIL “ERROR: Bad request - please check your parameters
400 - {“error”:{“code”:400,“message”:“Precondition check failed.”,“errors”:[{“message”:“Precondition check failed.”,“domain”:“global”,“reason”:“failedPrecondition”}],“status”:“FAILED_PRECONDITION”}}”

when trying to get an email or create email, anything related to GMAIL fails. However my credentials are OK (because I can get info using my credentials, with Google Sheet for example.

It is working well, but not with Gmail. I am using “Google API” credential type, as I was not able to create “Google OAUTH2 API” credential (unsafe localhost url). Should I use another kind of credential for GMAIL flows?

I am using 0.119.0 n8n in Synology NAS / Docker.

Thank you very much,

Here is the complete error:

Time
15/5/2021 12:38:17
HTTP-Code
400
Cause
Data below may contain sensitive information. Proceed with caution when sharing.
{
“name”: “StatusCodeError”,
“statusCode”: 400,
“message”: “400 - {“error”:{“code”:400,“message”:“Precondition check failed.”,“errors”:[{“message”:“Precondition check failed.”,“domain”:“global”,“reason”:“failedPrecondition”}],“status”:“FAILED_PRECONDITION”}}”,
“error”: {
“error”: {
“code”: 400,
“message”: “Precondition check failed.”,
“errors”: […], // 1 items
“status”: “FAILED_PRECONDITION”
}
},
“options”: {
“timeout”: 300000,
“headers”: {
“Accept”: “application/json”,
“Content-Type”: “application/json”,
“Authorization”: “Bearer ya29.c.KqgB_we51HbHMJnNUd4aeQav01bMVRpJQqN1ZyDKtmnuRJKf1kQasdiIUVLwopSdO4Qz5vzZPV_ETEzz9LpNTI34ast5tJGDXwCkZK5qjwk-97xrUlvrf9Zm9a8c2-izVyspHHYlMRwdFopc-uZfaI0KTUgn1CVWXdNTOv1pgmOnDfldDbBsW0fd899sDSVYld5G5OLMtYFrvvajbY9XIH4jK7FQZJ”
},
“method”: “GET”,
“qs”: {
},
“uri”: “https://www.googleapis.com/gmail/v1/users/me/labels”,
“qsStringifyOptions”: {
“arrayFormat”: “repeat”
},
“json”: true,
“simple”: true,
“resolveWithFullResponse”: false,
“transform2xxOnly”: false
},
“response”: {
“statusCode”: 400,
“body”: {
“error”: {…} // 4 keys
},
“headers”: {
“vary”: “X-Origin, Referer, Origin,Accept-Encoding”,
“content-type”: “application/json; charset=UTF-8”,
“date”: “Sat, 15 May 2021 10:38:17 GMT”,
“server”: “ESF”,
“cache-control”: “private”,
“x-xss-protection”: “0”,
“x-frame-options”: “SAMEORIGIN”,
“x-content-type-options”: “nosniff”,
“alt-svc”: “h3-29=”:443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v=“46,43"”,
“accept-ranges”: “none”,
“connection”: “close”,
“transfer-encoding”: “chunked”
},
“request”: {
“uri”: {…}, // 12 keys
“method”: “GET”,
“headers”: {…} // 3 keys
}
}
}
Stack
NodeApiError: Bad request - please check your parameters
at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Gmail/GenericFunctions.js:44:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Gmail/Gmail.node.js:160:36)
at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:424:47

I reply myself, I think that GMAIL needs OAUTH2 credentials only. I have setup Docker at my mac, at localhost, and I have been able to connect it OK.

Could you please confirm if GMAIL only works with OAUTH2 only?

Thanks

@Rl0_Tbz Gmail also can work with Service Account credentials BUT just when impersonating a user within an organization.

The Gmail API isn’t intended to be used with service accounts (other than domain-wide delegation use cases.) You need to be acting as a real user – either using oauth credentials obtained with user consent, or in the case of a Gsuite domain, using a service account delegating/impersonating a real user.