MTLS authentication & OAuth 2.0

Hi,

To connect to my bank, I need to implement MTLS authentication & OAuth 2.0.

I used to do it with a python script implemented in Pipedream.com. As it seems that I cannot run it on n8n because requests is not allowed, I’m trying to do it via HTTP, with the SSL certificate option and oauth2 without success.

I have this error, but everything seems to be correct:
{
“timestamp”: “2025-01-05T16:12:24.561+00:00”,
“path”: “/oauth/token”,
“status”: 404,
“error”: “Not Found”,
“requestId”: “39d20ae7-191551”,
“message”: “404 NOT_FOUND "No static resource oauth/token."”
}

For security reason, I will not share my workflow, but i can share the working python code to figure out how it works:

def get_access_token():
    try:
        # Create temporary files for the certificates (it only works with files)
        public_key_file_path, private_key_file_path, ca_cert_file_path = create_temp_files()
        auth = HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET)
        response = requests.post(
            f"{BASE_URL}{TOKEN_URL}",
            auth=auth,
            cert=(public_key_file_path, private_key_file_path),
            verify=ca_cert_file_path
        )
        response.raise_for_status()  # Raises an HTTPError for bad responses
        token = response.json().get('access_token')
        print(token)
        return token
    except Exception as e:
        print(f"Error fetching access token: {e}")
        return None
    finally:
        # Supprimer les fichiers temporaires
        delete_temp_files([public_key_file_path, private_key_file_path, ca_cert_file_path])

Thanks for your help.

Marc

Information on your n8n setup

  • n8n version: 1.72.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker, self-hosted locally with tunnel
  • Operating system: Windows 11

Hey @Marc_Kures

Welcome to the community :wave:

The 404 error sounds like the wrong url is being used at some point in your process, it is a fairly standard error that would be returned by the server you are working with.

It would be easier to see your workflow, unless you have added any credentials directly into the http request node and not used the credentials option there shouldn’t be anything sensitive in there but you could replace those values in the json with xxxx fairly easily in a text editor before sharing.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.