Trying to connect to the Amadeus API via oauth2 to get an access token.
I’ve tried several variations: importing the cURL, using the built in Credential for OAuth2 API. I’m able to get a token via postman and Terminal with no issue using:
{"status":"rejected","reason":{"message":"socket hang up","name":"Error","stack":"Error: socket hang up\n at connResetException (node:internal/errors:705:14)\n at TLSSocket.socketOnEnd (node:_http_client:518:23)\n at TLSSocket.emit (node:events:525:35)\n at TLSSocket.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1358:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)","config":{"url":"https://test.api.amadeus.com/v1/security/oauth2/token","method":"post","data":"grant_type=client_credentials&scope=&client_id=*******&client_secret=*********","headers":{"Accept":"application/json, application/x-www-form-urlencoded","Content-Type":"application/x-www-form-urlencoded","User-Agent":"axios/0.21.4","Content-Length":110},"transformRequest":[null],"timeout":300000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"axios-retry":{"retryCount":0,"lastRequestTime":1686773951483}},"code":"ECONNRESET"}}
Hi @tonybelonie, I am sorry you’re having trouble.
I tried out the Amadeus API in n8n and it seems to work fine. One thing worth pointing out here is that n8n handles the OAuth2-requests in the background. So in your HTTP request node you’d only make the call to the actual endpoint returning the data you are looking for.
On their Getting Started page this would be step 3 (“Calling the API”). To get this to work in n8n you would:
Make sure to select Client Credentials as the Grant Type. The Client ID is the API Key from the Amadeus developer portal, and the Client Secret is their API Secret.
Make a request to https://test.api.amadeus.com/v1/shopping/flight-destinations like so:
This example would return flight offers from Paris as expected:
Follow up on this – I copied your workflow and add my creds and continued to get the same error. I’m running n8n self hosted by this guide (Hetzner | n8n Docs) I tried running the workflow locally with no issues. I’ve investigated to the best of my knowledge but can’t understand why my self hosted instance won’t work with the same workflow given I followed all the steps listed in the guide. Any advice?
So fundamentally you’re the client in this scenario, trying to obtain data from Amadeus. socket hang up suggests the server (Amadeus) has not sent the expected answer but instead closed the connection. Seeing this works fine both on your local instance and on my own n8n instance it very much seems like this isn’t an n8n problem but a problem with your server.
Can you try connecting to your server via ssh and make the request outside of n8n from your server?
Is there a chance you are using a firewall limiting outbound connections? Do other HTTPS connections work for you (for example curl 'https://www.boredapi.com/api/activity')?
So if only the Amadeus requests fail (with or without n8n), but other requests are working this would very much suggest that your Hetzner IP is on some kind of blocklist by Amadeus (or one of their service providers), possibly because it has a bad reputation from its previous owner.
This can unfortunately happen with VPS IPs (but also rotating home IPs for example).
You could consider requesting a new IP from Hetzner here, or possibly use a proxy server to route your request.