Your 403 Forbidden error with “INSUFFICIENT_SCOPE” indicates a multi-layered authorization problem. Let me walk through the complete validation and fix process:
1. OAuth2 Scope Validation
First, decode both tokens (yours vs service account) to compare scope claims:
- Go to jwt.io and paste each token
- Look at the ‘scope’ claim in the payload section
- Your personal token likely includes: “API_JOURNALENTRY_SRV_0001 API_GLACCOUNTLINEITEM_SRV”
- The service account token probably shows: “openid profile” only
To fix the OAuth2 client configuration:
- In BTP Cockpit → Security → OAuth → Your OAuth Client
- Add Required Scopes: API_JOURNALENTRY_SRV_0001, API_GLACCOUNTLINEITEM_SRV
- Update the token endpoint request to include scope parameter:
scope=API_JOURNALENTRY_SRV_0001 API_GLACCOUNTLINEITEM_SRV
2. Service Account Permissions (SU01/PFCG)
Verify the service account SVCACC_FINPOST has these critical settings:
- User Type: System (correct)
- Account Number: Must be assigned if using Communication User pattern
- Password: Set and not expired (even for technical users)
In transaction PFCG for role Z_FI_API_POSTER, verify these authorization objects:
F_BKPF_BUK (Accounting Document: Authorization for Company Codes)
BUKRS: 1000, 2000 (your company codes)
ACTVT: 01 (Create), 02 (Change)
F_BKPF_GSB (Accounting Document: Authorization for Business Areas)
GSBER: * (or specific business areas)
ACTVT: 01, 02
F_BKPF_BLA (Accounting Document: Authorization for Posting Periods)
BUKRS: 1000, 2000
BELNR: *
GJAHR: 2024, 2025
3. PFCG Role Assignment to OAuth Scope
This is the critical missing link. The role must be mapped to the OAuth scope:
For S/4HANA Cloud:
- Transaction: Communication Arrangements
- Create/Edit arrangement for SAP_COM_0002 (or your custom scenario)
- Assign Communication User: SVCACC_FINPOST
- Map Business Role: Z_FI_API_POSTER
- Verify Scope Mapping includes: API_JOURNALENTRY_SRV_0001
For On-Premise S/4HANA:
- Transaction: SOAMANAGER → Service Administration
- Find service: API_JOURNALENTRY_SRV
- OAuth Configuration → Add Client ID
- Map Scope to User: SVCACC_FINPOST
- Assign Authorization Profile: Z_FI_API_POSTER
4. Token Claims Verification
After configuration changes, generate a new token and verify:
POST /oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=YOUR_CLIENT_ID
&client_secret=YOUR_SECRET
&scope=API_JOURNALENTRY_SRV_0001
Decode the returned token and confirm:
- ‘scope’ claim contains: “API_JOURNALENTRY_SRV_0001”
- ‘user_name’ or ‘sub’ claim shows: “SVCACC_FINPOST”
- ‘authorities’ array includes your authorization objects
Additional Checks:
- Run transaction SU53 immediately after the 403 error while logged in as SVCACC_FINPOST to see which authorization object failed
- Check transaction PFCG → Utilities → Mass Comparison to ensure role is properly generated and activated
- Verify in transaction SM19/SM20 (Security Audit Log) for detailed authorization failures
- If using SAP Cloud Connector, ensure the service account is in the principal propagation mapping
The root cause is almost always that the OAuth2 scope isn’t properly mapped to the PFCG role, so the token carries authentication but not the specific authorization for financial posting. Once you complete the scope-to-role mapping in step 3, regenerate your token with the explicit scope parameter, and the 403 should resolve to successful journal entry posting.