OData - Custom Authentication

0
We have a Mendix 10 application exposing an OData v4 service with custom authentication via a microflow. The microflow validates a JWT Bearer Token and returns a User entity.Our goal is to integrate Power BI and Tableau with this OData service using OAuth 2.0 delegated authentication (Azure Entra ID).The problem:When Power BI calls the OData endpoint without a Bearer Token, Mendix returns a 401 response but WITHOUT the WWW-Authenticate header. Power BI requires this header to know how to obtain an OAuth token automatically. Without it, Power BI shows the error: 'This credential type is not supported for this resource.'What we need:We need the Mendix OData 401 response to include:WWW-Authenticate: Bearer authorization_uri="https://login.microsoftonline.com/{tenant-id}", resource_id="{client-id}"
asked
2 answers
0

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.



answered
0

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:

  1. Open your Published OData Service and locate the Custom authentication microflow.

  2. Add a parameter of type System.HttpResponse to the authentication microflow.

  3. When the incoming request has no valid Bearer token, create a System.HttpHeader object.

  4. Set its values as follows:

    Key:

    WWW-Authenticate

    Value:

    Bearer authorization_uri="https://login.microsoftonline.com/<tenant-id>/oauth2/authorize"
  5. Associate the System.HttpHeader object with the System.HttpResponse parameter.

  6. Set the HttpResponse.StatusCode to 401.

  7. 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:

Hope this helps! If you find this answer helpful, please mark it as the accepted answer.

answered