I am getting an error with custom HTTP Requests using Oauth2 authentication:
ERROR: The client is not authorized to request an authorization code using this method.
Error: The client is not authorized to request an authorization code using this method.
at getAuthError (/usr/local/lib/node_modules/n8n/node_modules/client-oauth2/src/client-oauth2.js:122:15)
at /usr/local/lib/node_modules/n8n/node_modules/client-oauth2/src/client-oauth2.js:270:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/NodeExecuteFunctions.js:78:30
at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest.node.js:749:32)
at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:369:47
I reported this error to the service we are using (Exact Online), but they are asking me for request logs (which I can understand). I tried to catch the requests on my localhost (Mac) using mitmproxy, but for some reason that is not working.
Is there another way to log http requests so I can send debug information to Exact?
since we are using this module request-promise - npm to do the requests you can set an env variable NODE_DEBUG=request and you should be able to see all the request are being made on the terminal.
Is your answer with request-promise still valid? The logging documentation only mentions winston but winston is an app-level log, I couldn’t find a source for the “NODE_DEBUG” environment variable.
Up: I’ve explored n8n current codebase and it uses Axios. Axios doesn’t have an environment variable to enable debugging as it doesn’t use the “debug” package.
Instead an interceptor has to be configured, Axios docs lists a few solutions:
* [axios-curlirize](https://www.npmjs.com/package/axios-curlirize) - Logs axios requests as curl commands, also adds a property to the response object with the curl command as value.
However this means contributing to n8n codebase to add this option, since this requires setting up the interceptor when the axios client is created.
The relevant file in the n8n codebase seems to be :
packages/core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts
Legacy HTTP helpers seem to use Winston logger but they barely log anything anyway, and the new HTTP helper doesn’t have any logging included.