CLICLItypeA command you run, rather than a dependency you import.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

@saptools/cf-xsuaa

A command line and Node.js API that reads the XSUAA binding of a Cloud Foundry app and prints an OAuth2 client_credentials token for it, cached until it expires.

Calling a protected endpoint of a deployed app takes the app's own service token, and cf oauth-token returns the user's personal UAA token instead. cf-xsuaa fetch-secret pulls the client credentials of the app's XSUAA binding out of its VCAP_SERVICES, and get-token-cached prints a valid JWT for the app named by --region, --org, --space and --app, refreshing it before it goes stale. Region keys resolve to API endpoints through @saptools/cf-sync, and SAP_EMAIL and SAP_PASSWORD are needed only when the client secret has to be fetched again. Secrets and tokens are kept in ~/.saptools/xsuaa-data.json. The README names the client_credentials grant and no other.

Facts

Latestv0.2.1ReleasedLast pushLicenceMIT

Where it sits

Lives in
Provides
AuthenticationBTPAuthenticationcapabilityEstablishing who is calling: validating credentials or tokens, resolving the user, and making that identity available to the application. [Authorization](capability:authorization) decides what that identity may do; [identity provisioning](capability:identity-provisioning) manages its lifecycle across systems.
Runs
Cloud Foundry
Requires
SAP Authorization and Trust Management serviceSAP Authorization and Trust Management serviceartifactThe XSUAA binding of the target app, whose client credentials it reads from VCAP_SERVICES and exchanges for a client_credentials token.@saptools/cf-sync@saptools/cf-syncartifactResolving a region key such as ap10 to its Cloud Foundry API endpoint, so no URL is passed by hand.Node.jsNode.jsoutside the atlasIt is a Node command line and library, and the README names the Node version it needs beside the cf CLI on the PATH.

Who is behind it

Đông TrầnĐông TrầnPersonMaintains this
In the atlas: maintains 18, contributes to 18
@dongitran
maintainer

What it declares

Every artifact

Type
CLI
Origin
Independently maintained
Runs on
Cloud Foundry

As a CLI

Distributed through
npm

For authentication

Supports
Token with no userPasses the user onCorporate IdP behind it
property statedstated nonot said

Tasks this contributes to1Beta

Get a token for a protected BTP endpoint with no user signed inA script, a job or another service calls a protected endpoint of a deployed SAP BTP application and is accepted, with nobody at a browser.Coverstoken command line
What it does

Reads the XSUAA binding out of a deployed Cloud Foundry app and prints a client_credentials token for that app, which is the token a protected endpoint of it expects rather than the personal token cf oauth-token returns.

Remaining work

Install it on Node.js 20 or later with the cf CLI on the PATH, and supply SAP_EMAIL and SAP_PASSWORD for the first secret fetch. Nothing about the called endpoint's own validation changes.

All options on the Authentication page →

Connections5

@saptools/cf-xsuaa connections@saptools/cf-xsuaaPROVIDES→ provides1provides stated Obtains a token for a deployed application rather than for the person at the terminal: it reads that app's XSUAA binding and exchanges its client credentials for a JWT, which it reuses until the token expires. It validates nothing and logs nobody in; the grant it names is client_credentials and no other. dongitran/saptools — packages/cf-xsuaa/README.md: https://raw.githubusercontent.com/dongitran/saptools/main/packages/cf-xsuaa/README.md dongitran/saptools — packages/cf-xsuaa/README.md: https://raw.githubusercontent.com/dongitran/saptools/main/packages/cf-xsuaa/README.mdAuthenticationUSED BY← needed by1needed by derived Fetching or reusing the cached XSUAA token of the target app before every run. Through: inverted from its requires edge dongitran/saptools — packages/bruno/README.md: https://github.com/dongitran/saptools/blob/main/packages/bruno/README.md@saptools/brunoNEEDS→ needs3needs stated Resolving a region key such as ap10 to its Cloud Foundry API endpoint, so no URL is passed by hand. dongitran/saptools — packages/cf-xsuaa/README.md: https://github.com/dongitran/saptools/blob/main/packages/cf-xsuaa/README.md@saptools/cf-syncneeds stated It is a Node command line and library, and the README names the Node version it needs beside the cf CLI on the PATH. dongitran/saptools — packages/cf-xsuaa/README.md: https://github.com/dongitran/saptools/blob/main/packages/cf-xsuaa/README.mdNode.jsneeds stated The XSUAA binding of the target app, whose client credentials it reads from VCAP_SERVICES and exchanges for a client_credentials token. dongitran/saptools — packages/cf-xsuaa/README.md: https://github.com/dongitran/saptools/blob/main/packages/cf-xsuaa/README.mdSAP Authorization and Trust Managementservice

Install

npm add @saptools/cf-xsuaa

Derived from the package name. No recipe recorded; the README has the configuration.

Where @saptools/cf-xsuaa runsYour SAP BTP subaccountBy its type: a CLI is run from a terminalcallsdocumentedrequiresdocumentedrequiresdocumentedrequiresYour terminal, actorYour terminalNode.js, systemNode.jssystem@saptools/cf-xsuaa, module@saptools/cf-xsuaa@saptools/cf-sync, module@saptools/cf-syncSAP Authorization and Trust Management service, service instanceSAP Authorizationand TrustManagement service
SAPnot SAP's, or the project's ownstated in the documentdocumented only

README

quoted from dongitran/saptools under MIT, read
dongitran/saptools/packages/cf-xsuaa/README.mdOn GitHub

🔐 @saptools/cf-xsuaa

Stop copy-pasting XSUAA tokens from the BTP cockpit.

Fetch XSUAA credentials and OAuth2 access tokens from SAP BTP Cloud Foundry apps — straight from your terminal, with intelligent caching built in.

npm version license node install size types

Install • Quick Start • CLI • FAQ


✨ Features

  • 🔑 Zero-config OAuth2 — fetches client_credentials tokens straight from the XSUAA binding of any CF app
  • 💾 Smart caching — reuses tokens until they expire so you do not hand out stale JWTs
  • 🧩 CLI & API — drop into shell scripts, Node pipelines, or your favorite test runner
  • 🔗 CF-aware — resolves CF API endpoints from region keys via @saptools/cf-sync, no manual URLs
  • 🔒 Type-safe — shipped with full TypeScript definitions
  • 🪶 Tiny — one dependency (commander) and zero runtime magic

📦 Install

# Global CLI
npm install -g @saptools/cf-xsuaa

# Or as a dependency
npm install @saptools/cf-xsuaa
# pnpm add @saptools/cf-xsuaa
# yarn add @saptools/cf-xsuaa

Note

Requires Node.js ≥ 20 and the cf CLI on PATH. For the first secret fetch, set SAP_EMAIL and SAP_PASSWORD.


Updates

Every command first checks npm for a newer @saptools/cf-xsuaa (at most once an hour, one small request with a 2-second timeout) and, when one exists, installs that exact version with the package manager that owns the running binary and re-runs the command you typed on the new version. Both steps are announced on stderr; nothing is printed when the install is already current:

cf-xsuaa: updating 0.2.0 -> 0.3.0 ...
cf-xsuaa: updated to 0.3.0; re-running the command

If the install cannot complete, one stderr line gives the manual command and the command runs on the installed version; that version is not retried for a day. cf-xsuaa self-update forces the check and install now; cf-xsuaa self-update --check only reports.

ControlEffect
SAPTOOLS_AUTO_UPDATE=on|notify|offon (default) installs and re-runs; notify prints the manual command once per version; off never checks. Applies to every @saptools CLI.
CF_XSUAA_AUTO_UPDATEsame values, this CLI only; wins over the global variable
SAPTOOLS_UPDATE_INTERVAL_MINUTESminutes between checks (default 60; 0 checks on every run)
SAPTOOLS_NPM_REGISTRYregistry to check and install from (default: npm's configured registry, then npmjs)
SAPTOOLS_UPDATE_DEBUG=1explain on stderr why nothing happened

The updater switches itself off in CI (CI set), under NODE_ENV=test or NO_UPDATE_NOTIFIER, when the binary runs from a source checkout, an npm link or an npx cache, and inside the re-run itself. It never writes to stdout, never asks for input, never uses sudo, and never moves onto a prerelease. Its state lives in ~/.saptools/updates/.

🚀 Quick Start

# 1. Tell cf-xsuaa who you are (only needed for the first secret fetch)
export SAP_EMAIL="you@company.com"
export SAP_PASSWORD="your-sap-password"

# 2. Grab a token (auto-fetches the XSUAA binding on first call, caches it forever)
cf-xsuaa get-token-cached \
  --region ap10 --org my-org --space dev --app my-srv

That's it. Copy the printed JWT into curl, Postman, bruno, or wherever you need it. Next call reuses the cached token until it expires.


🧰 CLI

Every command identifies an app with the same four flags:

FlagDescriptionExample
-r, --region <key>CF region keyap10, eu10, us10
-o, --org <name>CF org namemy-org
-s, --space <name>CF space namedev
-a, --app <name>CF app namemy-srv
🔎 cf-xsuaa fetch-secret

Pull the XSUAA client credentials out of the app's VCAP_SERVICES and cache them to disk. Run this once per app, or whenever the binding rotates.

cf-xsuaa fetch-secret --region ap10 --org my-org --space dev --app my-srv
🎟️ cf-xsuaa get-token

Fetch a fresh OAuth2 client_credentials token and print the JWT to stdout. Auto-runs fetch-secret first if the binding isn't cached yet.

cf-xsuaa get-token --region ap10 --org my-org --space dev --app my-srv
⚡ cf-xsuaa get-token-cached

Return the cached token if it's still valid, otherwise fetch a new one. This is what you want 99% of the time.

TOKEN=$(cf-xsuaa get-token-cached --region ap10 --org my-org --space dev --app my-srv)
curl -H "Authorization: Bearer $TOKEN" https://my-srv.cfapps.ap10.hana.ondemand.com/api/health

Tip

Cached tokens are refreshed before they become stale, so callers do not receive a JWT that is about to expire.


📁 Output File

All state lives in a single JSON file under your home directory:

~/.saptools/xsuaa-data.json
🔬 Shape of xsuaa-data.json
{
  "version": 1,
  "entries": [
    {
      "region": "ap10",
      "org": "my-org",
      "space": "dev",
      "app": "my-srv",
      "credentials": {
        "clientId": "sb-xsappname!t123",
        "clientSecret": "<redacted>",
        "url": "https://my-org.authentication.ap10.hana.ondemand.com",
        "xsappname": "my-app!t123"
      },
      "token": {
        "accessToken": "eyJhbGciOi...",
        "expiresAt": "2026-04-18T12:34:56.000Z"
      },
      "fetchedAt": "2026-04-18T12:20:00.000Z"
    }
  ]
}

Important

Prefer the CLI or exported APIs over parsing this file directly — the on-disk format is an implementation detail.


❓ FAQ

Do I need SAP_EMAIL / SAP_PASSWORD on every call?

No. Those are only read when cf-xsuaa has to refresh the VCAP-bound client secret. Once the secret is cached, token refreshes go straight to the UAA with client_credentials — no SAP user credentials required.

How is this different from cf oauth-token?

cf oauth-token returns your personal UAA token. cf-xsuaa returns the app's own service token (issued to the XSUAA clientId in VCAP_SERVICES), which is what you actually need when calling the app's protected endpoints.

Is the cached token safe to commit?

No. ~/.saptools/xsuaa-data.json contains clientSecret and live JWTs. It lives under your home directory and should never be checked into git.

How do I invalidate a cached secret?

Run cf-xsuaa fetch-secret again with the same --region/--org/--space/--app flags and the entry will be overwritten.


🛠️ Development

From the monorepo root:

pnpm install
pnpm --filter @saptools/cf-xsuaa build
pnpm --filter @saptools/cf-xsuaa typecheck
pnpm --filter @saptools/cf-xsuaa test:unit
pnpm --filter @saptools/cf-xsuaa test:e2e

The e2e suite auto-discovers a real CF app with an xsuaa service binding by scoring candidates from ~/.saptools/cf-structure.json. To pin a specific target:

export E2E_TARGET="ap10/my-org/my-space/my-srv"


👨‍💻 Author

dongtran ✨

📄 License

MIT


Made with ❤️ to make your work life easier!

MIT, read

History

Latest

v0.2.1

  1. v0.2.0

  2. v0.1.11

  3. v0.1.10

  4. v0.1.9

  5. v0.1.8

  6. v0.1.7

  7. v0.1.6

  8. v0.1.5

  9. v0.1.4

  10. v0.1.3

  11. v0.1.2

  12. v0.1.0

On npm
6downloads per week, npm
Weekly downloads for @saptools/cf-xsuaa26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 6.27 Apr – 3 May: 5744 May – 10 May: 7811 May – 17 May: 4118 May – 24 May: 13325 May – 31 May: 521 Jun – 7 Jun: 438 Jun – 14 Jun: 7215 Jun – 21 Jun: 2922 Jun – 28 Jun: 7229 Jun – 5 Jul: 2766 Jul – 12 Jul: 4413 Jul – 19 Jul: 3220 Jul – 26 Jul: 3027 Jul – 2 Aug: 423 Aug – 9 Aug: 5410 Aug – 16 Aug: 5117 Aug – 23 Aug: 3224 Aug – 30 Aug: 2031 Aug – 6 Sept: 3717 Sept – 13 Sept: 5214 Sept – 20 Sept: 4021 Sept – 27 Sept: 2728 Sept – 4 Oct: 485 Oct – 11 Oct: 5312 Oct – 18 Oct: 1019 Oct – 25 Oct: 6
Authentication
  1. abap_jwt_generatorGenerates signed JSON Web Tokens in ABAPfrom ABAP
  2. @arc-mcp/xsuaa-authXSUAA authentication stack for an MCP server on SAP BTPfrom BTP/BAIP
  3. abap-pwnedpasswordsChecks passwords against Have I Been Pwned from ABAPfrom ABAP
  4. SAP Authorization and Trust Management serviceOAuth server issuing JWTs and holding scopes for BTP appsfrom BTP/BAIP
  5. Cloud Identity ServicesIdentity Authentication and Identity Provisioning as one tenantfrom BTP/BAIP
  6. SAP Customer Identity and Access Management for B2CRegistration, login and consent for customer-facing sitesfrom BTP/BAIP
  7. OAuth 2.0 on SAP BTPOAuth 2.0 grant flows for applications and APIs in Neo regionsfrom BTP/BAIP
  8. com.sap.cds:cds-feature-identityOAuth2 token validation from XSUAA and SAP Cloud Identity Servicesfrom CAP
  9. com.sap.cds:cds-feature-xsuaaFormer XSUAA JWT validation for CAP Java, removed in CAP Java 3.0from CAP
  10. abapOAuthAzureOA2C_SPECIFICS implementation for Microsoft Azure OAuth 2.0 in ABAPfrom ABAP
  11. abap2oauth2ABAP API for OAuth 2.0 authenticationfrom ABAP
  12. abapNTLMHTTP NTLM client for ABAPfrom ABAP
  13. abap_cloud_platformTypeScript library reaching ABAP service instances on Cloud Foundryfrom BTP/BAIP
  14. decodesapsso2TypeScript decoder for MYSAPSSO2 logon ticketsfrom ABAP
  15. @marianfoo/sap-mcp-authBrowser login and session module for SAP MCP serversfrom BTP/BAIP
  16. @sap/approuterSAP's Node.js application router in front of business applicationsfrom BTP/BAIP
  17. @sap/cdsCAP Node.js runtimefrom CAP
  18. Cloud ConnectorSAP's on-premises agent linking SAP BTP to customer-network systemsfrom BTP/BAIP
  19. @sap/xssecToken validation and security context for XSUAA and IASfrom CAP
  20. cds-azure-adAzure AD and Azure AD B2C authentication strategy for CAPfrom CAP
  21. cds-common-jwt-supportJWT authentication for CAP without xsuaa or xssecfrom CAP
  22. abap-aws-sigv4Signs outbound HTTP calls to AWS APIs with AWS Signature Version 4, directly from ABAP.from ABAP

Details

Sources4
Added by handdiscovered herechecked
npm registry, @saptools/cf-xsuaaversion, releases, installschecked
github.com/git+https://github.com/dongitran/saptools.gittree, pushes, contributors, CIchecked
packages/cf-xsuaa/README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
deploymentCloud Foundry
latestv0.2.1
first release
releases and cadence13, ~1d median
discovered viaAdded by hand
first seen in the atlas
ecosystem and domainbtp, security-and-compliance
History in the atlas2
  1. what it does, sources, one property
  2. First seen.
For your agent
Ref
artifact:saptools-cf-xsuaa
JSON
/artifacts/saptools-cf-xsuaa.json
MCP
Connecting an agent