Sub topic 3
Authentication and User Propagation
Assume you know basic REST, OData, OAuth 2.0, cloud services, and simple Node.js. This chapter connects those concepts to SAP BTP extensions.
Authentication and user propagation
A BTP application reaches S/4HANA through a destination. A destination stores the target URL and authentication settings. The Destination service supplies these settings to the application. Cloud Connector provides a controlled path to an on-premise S/4HANA system.
Use client credentials when the extension acts as itself. Use user propagation when S/4HANA must authorize the individual user. User propagation forwards a trusted user identity instead of sharing the user's password.
Common choices include:
OAuth2ClientCredentialsfor technical, application-to-application access.OAuth2UserTokenExchangeor principal propagation when the user's identity must reach S/4HANA.- Basic authentication only where legacy requirements make it unavoidable.
Consuming a released API with CAP
CAP (Cloud Application Programming Model) can expose a local service while forwarding queries to a released remote API. Configure the destination and imported API model, then connect the remote service in the handler.
const cds = require("@sap/cds");
module.exports = class PartnerReview extends cds.ApplicationService {
async init() {
const businessPartners = await cds.connect.to("API_BUSINESS_PARTNER");
this.on("READ", "BusinessPartners", request =>
businessPartners.run(request.query)
);
return super.init();
}
};The projection should expose only required fields and remain read-only when the extension does not own the data. Released APIs provide a stable contract for upgrades.
Reacting to business events
Use synchronous API calls when the user needs an immediate answer, such as checking a business partner. Use events when the extension can react later, such as updating a notification after a partner changes. Events reduce coupling, but consumers need retries, idempotency, and dead-letter handling.
Deciding which extension approach to use
| Need | Suitable approach |
|---|---|
| Small UI or field change for key users | In-app extensibility |
| Logic close to the S/4HANA transaction | Developer extensibility with ABAP Cloud |
| Independent application, integration, or separate release cycle | Side-by-side extension on BTP |
Check API release status, data ownership, latency, authorization, and upgrade impact before choosing.
Governance and lifecycle
Record the API, destination, authentication method, event contract, owner, and data classification. Review dependencies during each S/4HANA and BTP release. Monitor failed calls and event retries. Never depend on unreleased tables, internal classes, or direct database access.
Exercise
A nightly job reads blocked business partners, and no user is present. Should it use user propagation?
Show answer
Usually no. Use client credentials with a restricted technical identity, unless business rules require a specific user's authorization.