Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DestinationAccessException when fetching unauthenticated destinations via DestinationAccessor #709

Open
ktesnim opened this issue Jan 31, 2025 · 1 comment
Labels
question Further information is requested

Comments

@ktesnim
Copy link

ktesnim commented Jan 31, 2025

Ask the Question

Hello Team,

This is a follow up to the lately closed issue about "OAuth2JWTBearer" destination : #682
The suggested solution was fetching destinations via DestinationAccessor . In fact that helped us getting "Authorization" header for "OAuth2JWTBearer" destination, however we were not able to get unauthenticated destinations details anymore.

We have noticed that a DestinationAccessException was raised when fetching unauthenticated destinations :
com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Failed to read authentication token of destination 'xxxxxxx'. The destination service responded with an error: 'access_denied'. In case only the properties of a destination should be accessed, without performing authorization flows, please use the 'getDestinationProperties' method on 'DestinationService' instead.

In the other hand,we were able to get both authenticated and unauthenticated destination when querying the destination via REST client "v1/destination/v1/destination-configuration/v1/destinations/xxxxxx"

We believe that this behavior was related to the upgrade to SDK5 , because before we did the upgrade we used to fetch both authenticated and unauthenticated destination using Destination destination = DestinationAccessor.getLoader().tryGetDestination(destinationName).get();

So, is there any method provided by cloud-sdk-java to overcome this limitation ? any hint fro your side will be appreciated .

Best regards,
Tesnim

@ktesnim ktesnim added the question Further information is requested label Jan 31, 2025
@newtork
Copy link
Contributor

newtork commented Feb 4, 2025

I'm sorry to say, but there is no magic bullet to cover all cases.
You have to decide for either option:

  • "Get destination properties without intention of querying."
    Then use DestinationService#getDestinationProperties(String) (cached, performance)
  • "Get destination with intention of querying."
    Then use DestinationAccessor.getDestination(String).asHttp() (token handling by BTP Destination Service)

Note:
DestinationAccessor.getDestination(String) directs to DestinationAccessor.getLoader().tryGetDestination(String) implicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants