Http Auth | request

Hi n8n’ler,

i love your tool!

But one I don’t understand:

the node request:

I have an ext. application who want to request it.
By this applicaton I must send my user & password data to the app, the response is an token.
(I think it is a Basic Auth Method?)
example Request:
www.example.com/api/user/get_token?login=admin&password=admin
return:

{“token”: “24e635ff9cc74429bed3d420243f5aa6”}

www.example.com/api/res.partner/search/1?token=24e635ff9cc74429bed3d420243f5aa6

How can I use this external service in the node “request” ?

Must I send the request with no Auth and the token as parameter?

Perhaps someone can help me?

Best Regards

Hey, @se_we welcome to the community.

According to the example, both requests send the credentials using query parameters so no authentication has to be set on the node level.

1 - The first HTTP request node sends the login and password parameters using query parameters.
2 - The other HTTP requests that need the token will use expresions to reference the token returned by the first HTTP node and will send that info using the query parameter just like the first one.

Check the example below. If that does not solve your problem simply get back to us.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "www.example.com/api/user/get_token?login=admin&password=admin",
        "options": {},
        "queryParametersUi": {
          "parameter": [
            {
              "name": "login",
              "value": "admin"
            },
            {
              "name": "password",
              "value": "admin"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "url": "www.example.com/api/res.partner/search/1?token=24e635ff9cc74429bed3d420243f5aa6",
        "options": {},
        "queryParametersUi": {
          "parameter": [
            {
              "name": "token",
              "value": "use expresion"
            }
          ]
        }
      },
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes

Hello Ricardo,
thanks for your answer. I understand the method, thanks for your help.

(when I copy your Json code I only see one request in a loop…)

I think you mean: first request get the token and the second request makes the calls, or?

Not sure what you mean with a request loop. Both request are making a call just that the first one use the the credentials to get the token and the others requests use the token returned from the first call to “authenticate” the calls.

Hi Ricardo, your answer was absolutly correct, I only had an graphical error but I understand it since your first answer.

Thanks a lot for your support

@se_we glad you figured it out. Let us know if you have any further questions. Enjoy.