Skip to content

Commit

Permalink
Update Remote Services Docs with Recent Cloud SDK Improvements (#534)
Browse files Browse the repository at this point in the history
* Update for Cloud SDK 4.24+

* Update remote-services.md

* Update java/remote-services.md

* Update java/remote-services.md

* Update java/remote-services.md

* Update java/remote-services.md

Co-authored-by: Matthias Kuhr <[email protected]>

---------

Co-authored-by: Marc Becker <[email protected]>
  • Loading branch information
MatKuhr and beckermarc authored Nov 14, 2023
1 parent c2cf5bf commit ef7b8ef
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions java/remote-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ In this case, the destination with name `s4-business-partner-api` would be obtai
Given that this destination holds the URL `https://s4.sap.com`, the resulting service URL for OData requests would be `https://s4.sap.com/sap/opu/odata/sap/API_BUSINESS_PARTNER`.

The `type` property defines the protocol used by the remote API. The CAP Java SDK currently supports `odata-v4` (default) or `odata-v2`.
::: warning
When using SAP S/4HANA On-Premise via Cloud Connector with a non-default sap-client, you might observe 401 Unauthorized errors.
This is a known issue and can be avoided by adding an additional property `URL.headers.sap-client` with the value of the sap-client to the destination in the SAP BTP Destination Service's configuration.
:::

#### Configuring Destination Strategies

Expand Down Expand Up @@ -279,36 +275,27 @@ DefaultHttpDestination
#### OAuth2 Client Credentials { #oauth2-client-credentials}

```java
DefaultHttpDestination httpDestination = DefaultHttpDestination
.builder("https://example.org")
.name("my-destination").build();
ClientCredentials clientCredentials =
new ClientCredentials("clientid", "clientsecret");
ClientCredentialsHttpDestination clientCredentialsHttpDestination =
new ClientCredentialsHttpDestination(
httpDestination,
clientCredentials,
URI.create("https://xsuaa.url"),
new XsuaaService()
);
OAuth2DestinationBuilder
.forTargetUrl("https://example.org")
.withTokenEndpoint("https://xsuaa.url")
.withClient(clientCredentials, OnBehalfOf.TECHNICAL_USER_CURRENT_TENANT)
.withProperties(Map.of("name", "my-destination"))
.build();
```

#### User Token Authentication { #user-token-authentication}

```java
DefaultHttpDestination httpDestination = DefaultHttpDestination
.builder("https://example.org")
.name("my-destination").build();
ClientCredentials clientCredentials =
new ClientCredentials("clientid", "clientsecret");
ClientCredentialsHttpDestination clientCredentialsHttpDestination =
new ClientCredentialsHttpDestination(
httpDestination,
clientCredentials,
ClientCredentialsGrantType.USER_TOKEN,
URI.create("https://xsuaa.url"),
new XsuaaService()
);
OAuth2DestinationBuilder
.forTargetUrl("https://example.org")
.withTokenEndpoint("https://xsuaa.url")
.withClient(clientCredentials, OnBehalfOf.NAMED_USER_CURRENT_TENANT)
.withProperties(Map.of("name", "my-destination"))
.build();
```

0 comments on commit ef7b8ef

Please sign in to comment.