Issue using OAuth in appstore module E-mail module with templates

0
Hi community,I'm using the appstore module "E-mail module with templates" to send Email.Support from mendix is changed to community support since new modue Email Configurator is supported now.But due to a lot of rework there has been no upgrade yet since original module works fine for me.However when trying to use Oauth instead of basic authentication I'm having an issue.After filling OAuth data (client_id, client_secret and tenant_id) the button with class AzureConnect is pressed.Azure page is shown to login with Azure credentials of Email-account.Authentication is accepted but callback from Azure is not accepted by mendix app.Callback from Azure:https://swit-test.mendixcloud.com/callback_et/azure?code=1.AQsAqihVHmFGuE68RKQ6M3rmJ7PowYfgS8JCklJlT5tCNI4AAMMLAA.BQABBAIAAAADAOz_BQD0_0V2b1N0c0FydGlmYWN0cwIAAAAAAFn2DIEp3s3ahrKOJeZ4l3d7v1QPYT0cuJ0td6-gvxUFIeaztn6BdUlNhHmbtrc9Ypb3dWrjf7c7wiezGOz7FVpqXp9UfzzJ1GKjqfM1a5w5YzDesrAceKM93gYzDQQa3jTDhIJrPeaPP9tdoiEJEZFi6tvpeJ-4TICMzHjz2MDeimfI-XK3e32z4h6HRpMwfLv3RaR_g9o2xyp2ERCwT0kAaXbRoIO3aGR7R5thQr4c4aMXTFKO7sU7erjL9GivLAc61B38PgUVfceNz-ILq4y8YRNZ15rsAWxgQzlWWKr83xhFHsbik6BxHrdC17QiKTAFcBTD4eQ0jbDYG4DU0nHBj-5JFTyOTXZJaTgaEL3Zqj8HCC2iDOdCKSZZ4C7hLdPGlpPSeMl0WoQvM_lFy3j6USFWGcSQHViaC_conxT_aNbcZ7FmdNcw2R58sFsge046ZkAKRJ5IE9b0XrjSRqt3NKIVe06QC_7hbhfqlNpY97LHeFxB0_PBgGyuMnRv3HMygOwQLA16nONapP6IYpte5567lAUHEGP3Xrzg_6eGIeeIV8Md6pEeBhEmw25ZDXNEbFYYOhNKIp0gXPFT5jDrm1PkDFt2sPCavRpvfIOxjIjc1LNu8SLO5xTAAPcOo0q6ih3Q4tu3PbwcXzImPZoPQVzY5PQSNn-aGML9-kfHG8LfUxTMgu8xfLQhJnD-_R2odmTjfcN36YMgxG6W3H11jqLDNBSvEKNi11KgSZIqnofLSMr2FFhQb7HE0tQPHMBSatwwMDVL1AxEpkfbdWgkp54RWro6YcFIrdkIWBaeOfz-VPdPQbT3Yz9yJqFInrm-tG51agrrEsMJW9QUL9fi0yR6k_3IbN0H35m4aCIkK1irAf-aTgeYXfJFDh3C6NV57yyAykUCcU731Dy1DOBCOvaHDbag0NIkZOcCzEBZeV5v00uuRwUO10hBqgFQ6C-m6aylW1dSY9as5rapddtRE0IKCcFHYEfk95bDFMoXF00pH6-ryWa3wwzZLR2F31GnlR7yl9FWfJUy0J4bq-XdxobgzOZS2xbbDeWY9-TQseyQm1JcZuR9GXPaLXBADHo5GcLmF8aQgP5qlpHe9KohhGzu65wMuLqMLdzs3y84FqmgAKwFR36ZSKCtWAWtXsyqJNUpxLbtK1YZneYCQgiC7NX_Z7-_IkbmydrxjRXFQsWgmlJpWXbg00ix53L9zZXQCU9Z63NjUxfGE0-N2wo3HxZAVwN19TN9x-vM48ZLSElBWMMLF2FAg37YLpzOgSLCzgJ4AmBEEwLqJRCzwobLB1ZT8fxnS2RpDOYzyRKq_tUsZPuh&state=d5a7c3eb-0c0e-4e42-86ce-9e0325ddcb01&session_state=0020fd6a-1e84-19dd-4bcc-4c3bc90961b8#Error in browser when processing callback:HTTP ERROR 560In logging following error is shown:16:00:24runtime-container/hvmvnERRORSendEmail: Exception occurred while processing callback request java.lang.NullPointerException16:00:24runtime-container/hvmvnERRORConnector: null16:00:24runtime-container/hvmvncom.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.NullPointerException16:00:24runtime-container/hvmvnat com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:23)16:00:24runtime-container/hvmvn2026-02-16T15:00:24.838414909Z16:00:24runtime-container/hvmvnCaused by: java.lang.NullPointerException: null16:00:24runtime-container/hvmvnat emailtemplate.actions.OauthCallBackRequestHandler.processRequest(OauthCallBackRequestHandler.java:22)16:00:24runtime-container/hvmvnat com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:37)16:00:24runtime-container/hvmvnat com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1(MxRuntimeConnector.scala:54)16:00:24runtime-container/hvmvnat com.mendix.external.connector.MxRuntimeConnector.$anonfun$processRequest$1$adapted(MxRuntimeConnector.scala:54)16:00:24runtime-container/hvmvnat com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20)16:00:24runtime-container/hvmvnat com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.scala:54)16:00:24runtime-container/hvmvnat com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.scala:235)16:00:24runtime-container/hvmvnat com.mendix.m2ee.appcontainer.server.handler.RuntimeServlet.service(RuntimeServlet.scala:40)16:00:24runtime-container/hvmvnat javax.servlet.http.HttpServlet.service(HttpServlet.java:590)Is there anyone who can help solving this issue?Thanks in advance for your help.Gerard van den Broek.
asked
1 answers
1

hi,


The NullPointerException on the OAuth callback in the E-mail Module with Templates is a known issue caused by how that module manages the OAuth flow — and it only sometimes fails in Mendix Cloud because of session state issues during the redirect.

Why it fails

  1. The Email Templates module stores OAuth state in memory, not in persistent storage.
  2. Azure redirects back to your app (/callback_et/azure), but the module’s callback handler expects data in session or context that is no longer available.
  3. In Mendix Cloud, the callback may hit a different runtime instance with no session, leading to a NullPointerException in the handler (OauthCallBackRequestHandler.processRequest).

This behavior isn’t a bug in your configuration — it’s because the module’s callback flow isn’t designed to handle cross-site redirect state loss in a cloud cluster.

You can often see a similar failure when the session cookie is not sent during the redirect, because Mendix’s default SameSite=Strict setting blocks it. Other users have reported exactly this issue.

What the official documentation says

When configuring Microsoft Azure AD OAuth for the module, you must:

  • Register your app in Azure with the correct Redirect URI:

https://<yourappdomain>/<OAuthCallbackPath>/azure
  • (with OAuthCallbackPath from module constants)

The documentation does not explicitly cover cloud session behavior — that’s left to the community, and others have run into the same problem.

How to fix it (working approach)

1) Make sure Redirect URI is exact

In your Azure app registration, the redirect URI must exactly match:


https://<yourapp>.mendixcloud.com/callback_et/azure

including trailing path. A mismatch will not even reach your callback, but you do reach the callback in this case — so this part is correct.

2) Adjust SameSite cookie setting

Many OAuth callback problems (including in this module) are caused by Mendix session cookies not being sent across the Azure redirect.

By default Mendix marks cookies as SameSite=Strict.

To allow the OAuth callback to receive the session properly:

In Runtime Customization add:


com.mendix.core.SameSiteCookies=Lax

This allows the session cookie to be included during the cross-site redirect from Azure, which prevents the NullPointerException in the callback handler.

Important Notes

This issue is not a misconfiguration of Azure credentials — it’s the session state loss during OAuth redirect that triggers the exception.

The E-mail Templates module was moved to community support; it’s not maintained by Mendix anymore. If you rely on OAuth flows in production, the recommended supported module is Email Connector.

clean & correct

  • The callback error happens because the module cannot find the expected state when Azure redirects back — leading to a NullPointerException.
  • This often happens in Mendix Cloud when session cookies are not included due to SameSite=Strict.
  • The practical fix is to set SameSiteCookies=Lax via runtime customization.
  • For longer term or production usage, consider migrating to the supported Email Connector module.


answered