Generic notes for OAuth Authorization Code login against SAP Datasphere.
In System → Administration → App Integration, create an OAuth client with:
| Field | Value |
|---|---|
| Purpose | Interactive Usage |
| Authorization grant | Authorization Code |
| Redirect URI | Must match DSP_OAUTH_REDIRECT_URI exactly |
Copy Client ID, Client Secret, Authorization URL, and Token URL into .env.
- MCP or
npm run loginstarts a localhost callback server. - Browser opens the authorize URL.
- User completes IdP / SSO login.
- Redirect to
DSP_OAUTH_REDIRECT_URIwith?code=…. - Server exchanges code for tokens; stores
.token.json.
| Symptom | Check |
|---|---|
| HTTP 400 on authorize | Redirect URI mismatch; avoid unsupported prompt=login |
| Wrong account / tenant | Use private/incognito browser if another SSO session is cached |
client_id with | |
Must be URL-encoded in manual links (%7C) |
| API 401 | Token expired — run login_interactive or rely on refresh token |
Analytical 500 on $top only |
Model may require input parameters — use get_analytical_model then query_analytical_model with parameters |
| Wrong host | DSP_TENANT_URL must be *.hcs.cloud.sap, not *.authentication.* |
Consumption requests should include:
Authorization: Bearer <access_token>Accept: application/json(orapplication/xmlfor$metadata)Accept-Language: en(recommended)
Tokens are stored in .token.json (gitignored). Access tokens are short-lived; refresh tokens are used automatically when present.