cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Auth Token Destination Error: Failed to read authentication token.

08-09-2022 11:31 AM
30363 views 4 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Using CAP and SAP Cloud SDK to retrieve a destination of OAuth2SAMLBearerAssertion type.

We are currently using the following destination config:

In our CAP application, we are trying to access the destination using:

DestinationAccessor.getDestination(Constants.DEFAULT_S4_HANA_CLOUD);

However when we get the following error:

Failed to read authentication token. The destination service responded with an error: Retrieval of OAuthToken failed due to: Cannot determine user to propagate for OAuth2SAMLBearerAssertion destination. Either provide user_token JWT token (https://docs.cloudfoundry.org/api/uaa/version/4.7.1/index.html#user-token-grant) when retrieving the destination or configure it with SystemUser.

How can this be possible if I am able to get the token via the following?

AuthToken currentToken = AuthTokenAccessor.getCurrentToken();
AuthToken xsuaaServiceToken = AuthTokenAccessor.getXsuaaServiceToken();

I have also tried to authenticate with the token passed i.e.

AuthTokenAccessor.executeWithAuthToken(currentToken,  () -> DestinationAccessor.getDestination(Constants.DEFAULT_S4_HANA_CLOUD));

Are we missing a crucial step in the process? Has anyone encountered this issue before?

How are we able to correctly pass the AuthToken to the destination?

Thanks in Advance!

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

quovadis
Product and Topic Expert
Product and Topic Expert

Answers (1)

Answers (1)

PrasanthPadmanabhan
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Prasanth,

Thank you for your quick response. We have already configured this in our current BTP subaccount and S4HC (I'll double-check that this is the case). I think the problem lies in the Java/Cloud SDK setup since this is where we are getting the access issue.

Erlo

PrasanthPadmanabhan
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Erlo,

Additionally, you can refer to this reply in the blog that I've shared. https://blogs.sap.com/2021/03/24/oauth2samlbearerassertion-flow-with-the-sap-btp-destination-service.... A solution for a similar problem you are facing is shared here.

Best Regards,

Prasanth