How to login to Mautic automatically from my application

My Mautic version is: 3.3

I have installed Mautic in same server where I have my java web application. My web app does basic authentication in browser and lets user access it, now I have added a tab in my web app to access Mautic. User when clicks on this tab, user is redirected to login to Mautic and can access Mautic too.

My objective is not to show Mautic login and let user access Mautic from my web app directly. I understand both Mautic and my webapp should have same user profile.

I saw there is option to do SAML SSO but I dont want to authorize and introduce against any new IDP because my web app has already user authentication system.

I saw Mautic supports OAuth with Authorization Code grant type and Client Credential. I tried it with Postman and could get a token. OAuth authorization grant will ask for credentials once, which I dont want users to put credentials as they will be sent to login screen. Next, thought of using client credential grant but how will that map to user profile in Mautic, it simply provides access to Mautic pages like dashboard etc that does not user interaction so no access to contacts or cannot send email etc

So, my goal is that I dont want to show login page when redirecting from my web app to Mautic, is there any way to achieve this? Any help will be HIGHLY appeciated

Have a great day


Is this solved yet? I was looking for similar solution.

Well, I have done something similar in the past (not with Mautic but with WP and Flask app), I think you could try similar approach here. And before tying anything below I would make sure it really cannot be done with OAuth token

Somehow you need to set user cookies so request will be authenticated. I would try the following steps with Mautic:

  • Create a mautic plugin with custom route /myauth
  • During login process in your Java app you call /myauth route containing necessary details to login as specific mautic user (that would probably be user id or email if user does not exist in mautic database yet).
  • Investigate Mautic core - for sure there are methods you can use in your mautic plugin that would login user programmatically - you call them in /myauth endpoint (most likely methods for login are in UserBundle)
  • In addition to user details for /myauth you will typically want to include also redirect url to be used when user is logged in successfully,

That might be fun to try out, Drop me a message if you want me to assist you with plugin development.