question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrieved destination doesn't contain authTokens

See original GitHub issue

Hello all,

since I upgraded the @sap-cloud-sdk package from 1.53.x/1.54.x to 2.4.0, I’m facing the issue that retrieved destination does not include any authTokens although the forwardAuthToken property is set to true.

To clarify the problem, I have attached code and screenshots below of how the application behaved before and after the upgrade.

I am not sure if this is really an issue or if the behaviour is so desired. I wanted to report the behaviour anyway to find out if I am doing something wrong. If the behaviour is as desired as described below, can you tell me what I’m doing wrong or what I need to do differently to get authTokens with the destination?

Kind regards Johannes


Definition of destination in “User-Provided Variables” in the BTP

[ {
     "forwardAuthToken" : true,
     "name" : "myDestination",
      "url" : "https://<my-url>.cfapps.eu10.hana.ondemand.com"
} ]

Old behaviour

Used: version: "@sap-cloud-sdk/core": "1.53.1"

Calling the getDestination method:

	import * as coreCloud from "@sap-cloud-sdk/core";
	[...]
        const foundDestination = await coreCloud.getDestination("myDestination", {
             userJwt: <valid-user-token>,
             useCache: true,
	});
	[...]

Response: image

As you can see authTokens array is filled.

New behaviour

Used: version: "@sap-cloud-sdk/connectivity ": "2.4.0"

Calling the getDestination method:

	import * as connectivityCloud from "@sap-cloud-sdk/connectivity";
	[...]
        const foundDestination = await connectivityCloud.getDestination({
             destinationName: "myDestination",
             jwt: <valid-user-token>,
             useCache: true,
	});
	[...]

Response: image

As you can see authTokens array is not filled.

My finding

I debugged the sources of the two versions of the sdk. And it looks like that the part where the authTokens are added to the destination is not implemented in the new version.

Old implementation image

New implementation image

Used Versions:

  • node version: v14.19.2
  • npm version: 6.14.17
  • SAP Cloud SDK version: "@sap-cloud-sdk/connectivity ": "2.4.0"

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
FrankEssenbergercommented, Jun 13, 2022

Good morning @thisisevanfox,

here my first thoughts:

  • Can you help me out to get rid of my confusion? The registerDestination adds the destination to a key value store or cache if you want to call it that way. When you call then getDestination it will look at the env variable first, then the register destination cache and last the actual destination service. When a destination with the given name is found the flow is stopped and the result is returned. In the latest security validation it was pointed out that it is not a good practice to store destinations in environment variables because people could store too sensitive information in the environment. Therefore we introduced the register method and the env is stell there, but really meant for local test purpose.
  • Where to call registerDestination? Once at server start should be fine and you must do it before the first getDestiantion or executeHttpRequest call.
  • After calling registerDestination do I still need to call getDestination The executeHttpRequest does a lookup (calls getDestination) of the destination if you provide the DestinationFetchOption with the name of the registered destination. So you can directly use: executeHttpRequest({destinationName: 'nameOfRegisteredDestination', jwt: 'myJwtToPropagate')

I hope this helps.

Best Frank

0reactions
FrankEssenbergercommented, Jun 14, 2022

Thanks for the feedback. I close it and create a back log item to improve documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAP Cloud SDK - Accessing Auth Token Destination Error
Currently using CAP and SAP Cloud SDK to retrieve a destination of OAuth2SAMLBearerAssertion type. We have done the relevant setup in BTP ...
Read more >
using a destination with authentication type ... - GitHub
Currently the returned destination has no authToken and later when we build the header the token is added by hand.
Read more >
Troubleshooting | SAP Cloud SDK
You retrieved the destination but got an error when calling the cloud target system. This can have multiple reasons: The destination contains wrong...
Read more >
getDestination: Service of type successfactors is not supported
I have a CAP application where I want to use @sap-cloud-sdk/core to ... {"message":"Could not retrieve destination from service binding.
Read more >
Body worn integration API - Axis Communications
the clip has no duration. a user id or device id doesn't exist. 401 Unauthorized, Should be returned by content destination integration when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found