Hi Liliana,
I'm curious: Are you using the Mendix OIDC SSO module for API security, or are you validating the JWT entirely in your custom authentication microflow? I'm assuming you wrote your own?
Have you meanwhile been able to progress this issue?
Potentially this could be an enhancement in the OIDC SSO module, but this needs further investigation by one of our architects.
Hi Liliana,
You can return the WWW-Authenticate header directly from the custom authentication microflow of your Mendix Published OData service.
Mendix supports modifying the HTTP response through the System.HttpResponse parameter, including setting the status code and adding response headers.
Implementation in Mendix:
Open your Published OData Service and locate the Custom authentication microflow.
Add a parameter of type System.HttpResponse to the authentication microflow.
When the incoming request has no valid Bearer token, create a System.HttpHeader object.
Set its values as follows:
Key:
WWW-AuthenticateValue:
Bearer authorization_uri="https://login.microsoftonline.com/<tenant-id>/oauth2/authorize"Associate the System.HttpHeader object with the System.HttpResponse parameter.
Set the HttpResponse.StatusCode to 401.
Return an empty User object from the microflow.
Important: Mendix documentation states that response headers are returned when the custom authentication microflow sets a non-200 status code, except when the microflow returns an empty user.
Therefore, you must verify this behavior in your Mendix version. If the header is suppressed when the user is empty, the Published OData custom authentication mechanism cannot directly produce the required challenge in that configuration.
Recommended alternative: Azure API Management
If Mendix does not return the header as required, place Azure API Management in front of the OData endpoint.
Configure APIM to:
Return 401 Unauthorized with the correct WWW-Authenticate challenge for unauthenticated requests.
Forward valid Bearer tokens to Mendix.
Preserve the OData service endpoints and metadata.
Ensure token validation is performed securely by APIM and/or Mendix.
Microsoft documents this approach for Power Query integrations using Microsoft Entra ID authentication.
Power BI configuration:
Use the OData Feed connector and select Organizational Account.
Make sure the Entra ID application registration exposes the appropriate API resource/audience and permissions. The access token must be valid for the protected OData API.
One important limitation: Adding the challenge header is only the discovery step. It does not automatically make an arbitrary OData endpoint compatible with Power BI's built-in Organizational Account authentication. The resource/audience and OAuth flow must also be supported.
References:
Mendix Published OData Services: https://docs.mendix.com/refguide10/published-odata-services/
Microsoft Power Query Authentication: https://learn.microsoft.com/en-us/power-query/connectorauthentication
Microsoft Power Query OData Connector: https://learn.microsoft.com/en-us/power-query/connectors/odata-feed
Hope this helps! If you find this answer helpful, please mark it as the accepted answer.