How to send an API key in query parameters?

Hey!
I discover n8n and I’m quite impressed by the possibilities.

I have a question about authentication:
Is it possible to send an API key in query parameter without filling the key directly in the node? An equivalent of “Header Auth” but in query parameter.

Otherwise, as a workaround, is it possible to get the header auth value from an expression to use it as a query parameter?

The Hubspot API requires sending the API key like this (hapikey), and the Hubspot node doesn’t fit my needs.

Thanks!

Hey @fadrien,

Not a problem at all, if you look at the post here: Struggling with pagination there is an example workflow that shows how to connect to the Hubspot api using the http request node.

It isn’t a complete example but would get you started.

Out of interest what is missing from the Hubspot node for you?

2 Likes

Welcome to the community @fadrien!

Thanks, is great to hear that you like n8n!

No sorry, that is currently sadly not supported. As it was however very simply, did I just add support. It will be released with the next n8n version next week. In case you use Docker, you can also use the nightly build n8nio/n8n:nightly which should be available in around 8 minutes.

5 Likes

Thanks a lot @jan for this very quick and effective support!

@jon, I use Hubspot API to create notes on a contact based on events sent on a webhook by Sendinblue. So I have to make some POST requests on /engagements/v1/engagements: Create an Engagement | Engagements API

1 Like

Hi @fadrien ,

In the example workflow that @Jon referred to, I was using a slightly different connection mechanism at the Hubspot end - rather than using the standard API key approach I had created a private app (see help docs here for explanation).

It’s pretty easy to create one of these in Hubspot and it is better because you’ll get a Hubspot access token which is dedicated to your app / integration, otherwise Hubspot seem to only have a single API key to be shared across everything that integrates to the REST API (which is a pain if you ever need to rotate the keys because all integrations have to be changed!).

When using this method instead of putting the hapikey on the url when making your POST, you will need to create an Authorization header with a value of

Bearer <insert your private app token here>

See example image:

Regards
Scott

2 Likes

Hi @scottjscott,
Thanks for the details, I didn’t know it was possible to authenticate with a private app token. This sounds like the perfect solution!

1 Like

Obviously your token is then in the flow rather than nicely secured away in your n8n authentications - i.e. be careful about what you share as you could then expose your token. :slight_smile:

@scottjscott you can create an Header Auth, it works fine

image

Doh! Thanks for pointing that out, it just hadn’t occurred to me. Every day is a school day :smiley:

2 Likes

Got released with [email protected]

1 Like