After reviewing all the symptoms, here’s the complete solution addressing your Fiori OData authentication issue, SAML2 SSO session handling, and proper Gateway trace analysis:
Root Cause Analysis:
Your issue stems from three configuration gaps in the cloud SSO setup:
-
Fiori OData Authentication Flow: The destination configuration needs ‘OAuth2SAMLBearerAssertion’ instead of ‘PrincipalPropagation’ for cloud Fiori apps. This ensures the SAML assertion is exchanged for an OAuth bearer token that can be used for OData calls.
-
SAML2 SSO Session Handling: Configure these critical parameters in your destination:
Authentication: OAuth2SAMLBearerAssertion
tokenServiceURL: https://<tenant>.authentication.sap.hana.ondemand.com/oauth/token
clientKey: <your-oauth-client>
authnContextClassRef: urn:oasis:names:tc:SAML:2.0:ac:classes:X509
- SAP Gateway Trace Analysis: In /IWFND/ERROR_LOG, filter by your user and timestamp. Look for entries showing ‘Authentication Method: OAuth2’. If you see ‘Anonymous’ or ‘Basic’, the bearer token isn’t reaching the gateway.
Complete Solution Steps:
A. Update Cloud Connector Configuration:
- Set Principal Type to ‘None’ (let destination handle authentication)
- Ensure cloud-to-onpremise mapping includes your backend system
- Verify protocol is HTTPS for token exchange
B. Reconfigure BTP Destination:
- Change Authentication from ‘PrincipalPropagation’ to ‘OAuth2SAMLBearerAssertion’
- Add the tokenServiceURL for your BTP subaccount
- Set nameIdFormat: ‘urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress’
- Enable ‘Use default JDK truststore’
C. Update Fiori App xs-app.json:
Ensure your route forwards authentication:
{
"source": "^/sap/opu/odata/(.*)",
"authenticationType": "xsuaa",
"destination": "S4HANA_BACKEND"
}
D. Gateway Service Configuration (SICF):
- Transaction SICF → navigate to /sap/opu/odata/sap/TRIP_APPROVE_SRV
- Handler List → Select service handler
- Security Requirements → Enable ‘OAuth 2.0’ in addition to SSO
- Save and activate
E. Verify OAuth Scope:
In BTP Cockpit → Security → OAuth Clients, ensure your client has the scope ‘uaa.resource’ and the OData service technical user has the required authorizations (transaction SU01, role SAP_GATEWAY_USER).
Testing & Validation:
- Clear browser cache and cookies completely
- Login via Fiori launchpad - you should see OAuth token exchange in browser network tab
- Submit expense report - OData POST should include ‘Authorization: Bearer ’ header
- Check /IWFND/ERROR_LOG - authentication method should show ‘OAuth2’ with your user principal
- If still failing, check /IWFND/GW_CLIENT → Test Service → use ‘OAuth’ authentication type
Gateway Trace Analysis Commands:
/IWFND/TRACES - Enable trace for user, run transaction, analyze
Look for: 'OAuth Token Validation: Success'
If you see 'Token expired' - check token lifetime in OAuth client config
The key insight is that cloud Fiori apps require OAuth bearer token flow, not direct cookie-based SSO. The SAML assertion authenticates the user initially, then gets exchanged for an OAuth token that travels with each OData request. This solves the cross-origin cookie issues and provides proper token-based authentication for microservices architecture.
After implementing these changes, your 401 errors should resolve and Gateway traces will show successful OAuth authentication for all OData calls.