Custom node - get header response for auth

Hi,

i am working on a custom node. First i have to login by Basic-Auth, after i have to use, from response a header element (‘X-ACCESS-TOKEN’), for further queries. i didnt find a node wich are using this authentication method.

with the examples on docs.n8n.io, i only have this:

            const options: OptionsWithUri = {
                headers: {
                    'Accept': 'application/json',
                },
                method: 'POST',
                uri: `https://api.example.com/api/session`,
                auth: {
                	username: `${username}`,
                	password: `${password}`
                }
                json: true,
            };

            responseData = await this.helpers.request(options);

The responseData doesnt include the header information, right?
i try it with

return responseData.headers.get(‘X-ACCESS-TOKEN’);

But no success. Thanks.

Hi @ChristianV

You will need to add:
resolveWithFullResponse: true,
to your Options.
After adding this, the complete response is returned which also includes the headers.

Yes, i tryed this, but i get the following error:

Object literal may only specify known properties, and ‘resolveWithFullResponse’ does not exist in type ‘OptionsWithUri’.

@ChristianV

You are correct, sorry. You will need to add
//@ts-ignore
aswell

See the Ocilion node for an example :wink: :
image

4 Likes

no comment, i didn’t check that myself, that here is the same principle. :roll_eyes: :man_facepalming: thanks for your answer!

2 Likes