Skip to content

Commit b0d5fed

Browse files
author
tomfrenken
committed
add docs
1 parent 5ca6a0e commit b0d5fed

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

docs-js/features/connectivity/destination.mdx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,44 @@ The SAP Cloud SDK provides a default implementation for the transformation of se
200200

201201
The default implementation also retrieves a service token, if needed.
202202

203+
Additionally, we provide a default implementation for the transformation of service bindings to OAuth2ClientCredentials destinations.
204+
205+
It assumes that your service binding is of the following structure:
206+
207+
```json
208+
{
209+
"VCAP_SERVICES": {
210+
"custom-service": [
211+
{
212+
"name": "my-custom-service",
213+
"label": "custom-service",
214+
"tags": ["custom-service"],
215+
"url": "https://example.com",
216+
"credentials": {
217+
"clientid": "CLIENT_ID",
218+
"clientsecret": "CLIENT_SECRET",
219+
}
220+
}
221+
]
222+
}
223+
}
224+
```
225+
226+
If your service url is not in the `url` property, you can alternatively provide a `url` property as part of the `options` object.
227+
228+
The following is a multi-tenant example, where the user's jwt is used for tenant-isolation in the cache together with a custom url as target.
229+
230+
```ts
231+
const serviceBinding = getServiceBinding('custom-service');
232+
const userJwt = retrieveJwt(request);
233+
const destination = getDestinationFromServiceBinding({
234+
destinationName: 'custom-service',
235+
jwt: userJwt,
236+
useCache: true,
237+
transformServiceBindingToClientCredentialsDestination(serviceBinding, { url: 'custom-url', jwt: userJwt })
238+
})
239+
```
240+
203241
For other types of service bindings or if you want to overwrite the default behavior, provide a callback function (`serviceBindingTransformFn()`) in the request execution.
204242

205243
For example, if you have a binding for a custom service:
@@ -210,8 +248,8 @@ For example, if you have a binding for a custom service:
210248
"custom-service": [
211249
// This object is passed to `serviceBindingTransformFn()`
212250
{
213-
"label": "custom-service",
214251
"name": "my-custom-service",
252+
"label": "custom-service",
215253
"credentials": {
216254
"url": "https://example.com",
217255
"usr": "USERNAME",

0 commit comments

Comments
 (0)