I would like to report what I experienced with Mautic API, at least when connecting via n8n. I think this is a bug (plus, maybe, an unexpected behaviour). Not able to investigate further because of my lack of experience.
- Perform a fresh Mautic install with Cloudron
- Configure Mautic to use OAuth2 by creating API credentials
- Try to connect to Mautic API via n8n by setting up a new account (classic configuration : callback URL reported into Mautic API configuration, Mautic URL, Mautic client ID & secret)
- Under n8n a popup opens asking to log in Mautic (not really sure if it is a normal behaviour when you use OAuth2 instead of HTTP basic auth... anyway)
- Enter any account credentials coming from Cloudron LDAP (important) and try to log in
- Get a "Invalid credentials" error message
Already investigated :
- some report of this bug exist (StackOverflow, Mautic Community) and people say to clear cache - I tried it, didn't work
- some others report report an old bug (apparently fixed) making you need to activate "Basic HTTP Auth" even if you perform OAuth2, which is a nonsense - I tried it, juste to make sure, didn't work
- apparently, this bug seems impossible to reproduce impossible to reproduce when using credentials of a local Mautic account at step 5 - I then suspect a specific bug with Cloudron LDAP accounts
So, I don't need direct support as I apparently found a workaround. Anyway, I guess it would be useful to investigate further.
Thank you for your answers.
@robi I use cloudron username. It would be strange to use email, as the expeted login is Mautic login which is basically the login managed by Cloudron, which is username-based, not email-based. No?
@girish I am not sure to understand your point. I think the the problem is not on n8n side but on the Mautic side. But if you mean that the problem might lie in the use of basic auth from n8n, I confirm that I do not use basic auth but OAuth2. Do you think the removal of basic auth in n8n would help in any way ? My current version of n8n is 0.166.0.
@thibaud I think just to keep things simpler, please check if just simple mautic API works using curl.
By OAuth, I guess you mean the Mautic's "OAuth2" i.e the one described in https://www.mautic.org/blog/developer/how-to-use-the-mautic-rest-api ? I have no clue how that works...
But for our own mautic automation, we first enable the API like this:
Then, we use http basic auth. We then created a separate user called mauticbot (added straight inside mautic). We then use https://github.com/vdavid/node-mautic to automate. That module just uses the account username and password and no API token.