Skip to content

Commit ff34af9

Browse files
committed
chore: update IAS helpers to document 'identity' as preferred service argument
1 parent d536758 commit ff34af9

1 file changed

Lines changed: 28 additions & 25 deletions

File tree

  • docs-js/features/connectivity

docs-js/features/connectivity/ias.mdx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ const destination = await getDestinationFromServiceBinding({
251251
The SAP Cloud SDK provides two convenience functions for working with IAS tokens directly.
252252
These are useful when you need access to the IAS token or destination, for example outside SAP BTP environments with pre-populated `VCAP_SERVICES` or when constructing a destination manually.
253253

254-
Both functions accept a service as `Service | string | ServiceCredentials`, unlike `getDestinationFromServiceBinding()` they also accept bare `ServiceCredentials` (e.g., just `clientid`, `clientsecret`, and `url`).
254+
Both functions accept either the string `'identity'` (preferred, resolves the binding from `VCAP_SERVICES`) or bare `ServiceCredentials` (e.g., just `clientid`, `clientsecret`, and `url`).
255+
256+
:::tip
257+
258+
Pass `'identity'` whenever possible to let the SAP Cloud SDK resolve the IAS service binding from the environment, avoiding manual handling of credentials.
259+
260+
:::
255261

256262
- **[`getIasDestination()`](pathname:///api/v4/functions/sap-cloud-sdk_connectivity.getIasDestination.html)** fetches an IAS token and builds a ready-to-use [`Destination`](pathname:///api/v4/interfaces/sap-cloud-sdk_connectivity.Destination.html) with the token, the target URL, and the mTLS key pair from the service binding credentials (if present).
257263
- **[`getIasToken()`](pathname:///api/v4/functions/sap-cloud-sdk_connectivity.getIasToken.html)** fetches an IAS token and returns an [`IasTokenResult`](pathname:///api/v4/interfaces/sap-cloud-sdk_connectivity.IasTokenResult.html) with the access token string, its expiration, and an optional refresh token.
@@ -272,32 +278,29 @@ The `targetUrl` is ignored if `getIasToken()` is used.
272278
import { getIasDestination, getIasToken } from '@sap-cloud-sdk/connectivity';
273279

274280
// Use getIasDestination() to build a destination (technical user)
275-
const destination = await getIasDestination(
276-
{
277-
clientid: 'CLIENT_ID',
278-
clientsecret: 'CLIENT_SECRET',
279-
url: 'https://my-ias.accounts.ondemand.com'
280-
},
281-
{
282-
targetUrl: 'https://backend-provider.example.com',
283-
jwt: JWT_PAYLOAD,
284-
requestAs: 'current-tenant',
285-
resource: { name: 'backend-api' }
286-
}
287-
);
281+
// Preferred: pass 'identity' to resolve the binding from VCAP_SERVICES
282+
const destination = await getIasDestination('identity', {
283+
targetUrl: 'https://backend-provider.example.com',
284+
jwt: JWT_PAYLOAD,
285+
requestAs: 'current-tenant',
286+
resource: { name: 'backend-api' }
287+
});
288288

289289
// Use getIasToken() to retrieve an IAS token (business user)
290-
const token = await getIasToken(
291-
{
292-
clientid: 'CLIENT_ID',
293-
clientsecret: 'CLIENT_SECRET',
294-
url: 'https://my-ias.accounts.ondemand.com'
295-
},
296-
{
297-
authenticationType: 'OAuth2JWTBearer',
298-
assertion: JWT_ASSERTION,
299-
resource: { name: 'backend-api' }
300-
}
290+
// Preferred: pass 'identity' to resolve the binding from VCAP_SERVICES
291+
const token = await getIasToken('identity', {
292+
authenticationType: 'OAuth2JWTBearer',
293+
assertion: JWT_ASSERTION,
294+
resource: { name: 'backend-api' }
295+
});
296+
```
297+
298+
If `VCAP_SERVICES` is not available (e.g. outside SAP BTP), pass `ServiceCredentials` directly instead:
299+
300+
```typescript
301+
const destination = await getIasDestination(
302+
{ clientid: 'CLIENT_ID', clientsecret: 'CLIENT_SECRET', url: 'https://my-ias.accounts.ondemand.com' },
303+
{ targetUrl: 'https://backend-provider.example.com', resource: { name: 'backend-api' } }
301304
);
302305
```
303306

0 commit comments

Comments
 (0)