We’re integrating our quote management system with SAP S/4HANA 1809 using REST APIs and hitting a persistent 401 Unauthorized error specifically on compliance audit endpoints. The OAuth2 client has been configured with the SAP_COM_0109 communication arrangement role and works perfectly for all other API calls - quote creation, pricing updates, customer data retrieval all function without issues.
The problem is isolated to endpoints under /sap/opu/odata/sap/API_COMPLIANCE_AUDIT_SRV/ path. Same token, same headers, but these endpoints consistently reject our requests:
Our token validation shows it’s still valid with 45 minutes remaining. Has anyone encountered this selective endpoint authentication failure? We need these audit trail APIs operational for regulatory compliance reporting.
These scopes are NOT automatically derived from SAP_COM_0109. They must be explicitly requested during token generation.
Communication Arrangement Verification - In transaction CO_ARRANGEMENT, open your SAP_COM_0109 arrangement and verify:
Service URL includes /API_COMPLIANCE_AUDIT_SRV
Authentication Method = OAuth 2.0
Under “Outbound Services” tab, ensure AuditLogRead and AuditLogWrite are both checked
The “Scope” field should list: COMPLIANCE_AUDIT_API
ICF Service Activation - Transaction SICF, navigate to /default_host/sap/opu/odata/sap/API_COMPLIANCE_AUDIT_SRV and ensure:
Service is active (green light)
Handler List includes CL_COMPLIANCE_AUDIT_DPC_EXT
No authentication required at ICF level (OAuth2 handles it)
Token Validation - The 401 with “invalid_token” error specifically on audit endpoints means your token lacks audit-specific claims. Decode your JWT token (use jwt.io) and verify the “scope” claim includes the compliance audit scopes. If it doesn’t, your authorization server isn’t issuing them even if requested.
Backend Trace Analysis - Enable trace in transaction STAUTHTRACE for your service user. Reproduce the 401 error, then check the trace. It will show exactly which authorization check is failing - usually it’s either the scope validation or the S_APPL_LOG check happening first.
The key insight: SAP separates API authentication (OAuth2 token validity) from API authorization (what that token can access). Audit endpoints have an additional compliance authorization layer that requires explicit scope configuration. The fact that other APIs work proves your OAuth2 setup is fundamentally correct - you just need to add the audit-specific scope to your token requests and ensure the backend authorization objects are assigned.
After making these changes, clear the OAuth2 token cache on your client side and request a fresh token with the updated scopes. The 401 should resolve immediately if all six points are addressed.
This draft is based on general SAP S/4HANA knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.
I’ve seen similar behavior when the OAuth2 scope doesn’t explicitly include audit-specific permissions. Even with SAP_COM_0109 role assigned, audit endpoints often require an additional scope parameter in your token request. Check if your authorization server configuration includes ‘COMPLIANCE_AUDIT_READ’ or ‘AUDIT_LOG_WRITE’ scopes. The token might be valid for general APIs but lack the granular permission needed for compliance data access.
This is a known security restriction in 1809. Compliance audit endpoints have separate authorization objects (F_BKPF_GSB and S_RFC specifically) that aren’t automatically inherited from the communication arrangement role. Your OAuth2 client service user needs explicit assignment of authorization object S_APPL_LOG with ACTVT=03 for display and ACTVT=01 for create operations on audit logs. Check transaction PFCG to verify the service user’s role includes these objects. Without them, the API gateway rejects requests even with valid OAuth2 tokens because backend authorization fails.
Thanks both. I verified the service user roles in PFCG and S_APPL_LOG was indeed missing. Added it with ACTVT 01 and 03 but still getting 401. The scope suggestion is interesting - where exactly do I configure these additional scopes? In the communication arrangement or in the OAuth2 client registration on our authorization server side?
You need both. First, in SAP transaction /IWFND/MAINT_SERVICE, verify that API_COMPLIANCE_AUDIT_SRV service is activated and the technical user has ICF node access. Second, in your OAuth2 client configuration (wherever you’re managing tokens), add scope=‘COMPLIANCE_AUDIT_API’ to the token request parameters. The communication arrangement in SAP defines what the service user CAN do, but the OAuth2 scope defines what the token IS ALLOWED to request. They work together - missing either piece causes this exact symptom where other APIs work but audit endpoints don’t.
Also check table AGR_TCODES for your service user’s assigned roles. Even with correct authorization objects, if transaction code SOST or SACF isn’t included in the role profile, audit log access gets blocked at the transaction level. This is separate from the API authorization layer and often overlooked. You can test this by trying to access the audit log manually through the SAP GUI with the same service user credentials.
Confirmed this resolves the OAuth2 401 errors on compliance audit endpoints after adding S_APPL_LOG and F_BKPF_GSB authorization objects to our technical service user in PFCG.