What is the equivalent http request with auth in code node

Describe the problem/error/question

I can make a post request using the http request node:

  • url: as normal
  • credential type: Google Firebase Cloud Firestore OAuth
  • Credential name: firebaseCredentials

And this works correctly. My question is: how do I make the equivalent call using

const options = {url: "myurl"}

const response = await this.helpers.httpRequestWithAuthentication.call(
	this, 
	'firebaseCredentials', 
	options,
);
return response

What is the error message (if any)?

when I run it, I get: Problem in node ‘Code‘

this.getNode is not a function [line 3]

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Using cloud version 1.36.1

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Using cloud version 1.36.1

Also, just upgraded to 1.38.2, and same result.

The issue here is that this in this.helpers.httpRequestWithAuthentication.call(this is not IExecuteFunctions, but the global object of the sandbox.
It would be a security risk to expose the actual this inside the code node, so we might have to .bind all the helper functions when the JS sandbox is created.

1 Like

So, do I need to do anything else regarding this? (report as a bug somewhere, or anything else)

Hi, just wondering, is this going to be fixed in a coming update?

There is a PR in that may fix this it just needs to be reviewed.

1 Like

This was fixed and released in 1.42.0