I have a test on-premises Exchange server in internal network, which is externalized with Azure Application Proxy. When accessing the external url with EWS endpoint (/ews/exchange.asmx) from a browser, user is redirected to Microsoft login page, as expected. After authentication user is being navigated to EWS endpoint, also as expected:

Enterprise Applications setup:
- User is added to "Users and groups".
- "Single sign-on" is set to "IWA".
- Everything else is set to default.
App Registrations setup:
- "iOS/macOS" platform is added in "Authenticaion" with correct bundleId.
- Everything else is set to default.
I have an iOS application with MSAL library integrated, an access token is acquired with this parameters:
- clientId: "Application (client) ID" copied from "App registrations" -> "Overview"
- authority: "https://login.microsoftonline.com/{Directory (tenant) ID}" copied from "App registrations" -> "Overview"
- redirectUri: "msauth.{bundle_id}://auth" same as in "App registrations" -> "Authentication"
- scopes: "https://{external_url}.msappproxy.net//user_impersonation"
Access token is acquired without any issues. Here are the decoded contents:
{
"aud": "https://{external_url}.msappproxy.net/",
"iss": "https://sts.windows.net/{Directory (tenant) ID}/",
"iat": 1678210180,
"nbf": 1678210180,
"exp": 1678214664,
"acr": "1",
"aio": "{Don't know what this is, can provide if necessary}",
"amr": [
"pwd",
"rsa"
],
"appid": "{Application (client) ID}",
"appidacr": "0",
"deviceid": "{device_id}",
"family_name": "{family_name}",
"given_name": "{given_name}",
"ipaddr": "{ip_address}",
"name": "{name}",
"oid": "{uuid_1}",
"onprem_sid": "{sid_1}",
"rh": "{Don't know what this is, can provide if necessary}",
"scp": "user_impersonation",
"sub": "{uuid_2}",
"tid": "{uuid_3}",
"unique_name": "{same_as_upn}",
"upn": "{upn}",
"uti": "{Don't know what this is, can provide if necessary}",
"ver": "1.0",
"onpremisessamaccountname": "{upn_without_domain}"
}
When I use this token to access the webpage with external url, I receive a redirect (302) to Microsoft login page:
https://login.microsoftonline.com/{tenant_id}/oauth2/authorize?response_type=code&client_id={client_id}&scope=openid&nonce={uuid_1}&redirect_uri=https://{external_url}.msappproxy.net/&state=AppProxyState:{"InvalidTokenRetry":true,"IsMsofba":false,"OriginalRawUrl":"https://{external_url}.msappproxy.net/EWS/Exchange.asmx","RequestProfileId":"{uuid_2}","SessionId":"{uuid_3}"}#EndOfStateParam#&client-request-id={uuid_4}
I have had this setup numerous times, and never had this kind of issue. I have no clue what to look for anymore, any kind of help is deeply appreciated!
This issue was also reported on MSAL iOS github page:
https://github.com/AzureAD/microsoft-authentication-library-for-objc/issues/1665