title: SAP Cloud SDK - Accessing Auth Token Destination Error: Failed to read authentication token
body: <p>Currently using CAP and SAP Cloud SDK to retrieve a destination of OAuth2SAMLBearerAssertion type.
  We have done the relevant setup in BTP and S4HC found here: <a href="https://blogs.sap.com/2021/05/10/oauth2samlbearerassertion-flow-with-the-sap-btp-destination-service.-s-4hana-cloud./" rel="nofollow noreferrer">https://blogs.sap.com/2021/05/10/oauth2samlbearerassertion-flow-with-the-sap-btp-destination-service.-s-4hana-cloud./</a></p>
  <p>We are currently using the following destination config:
  <a href="https://i.stack.imgur.com/9ciHS.png" rel="nofollow noreferrer">Destination Config</a></p>
  <p>In our CAP application, we are trying to access the destination using:</p>
  <pre><code>DestinationAccessor.getDestination(Constants.DEFAULT_S4_HANA_CLOUD);
  </code></pre>
  <p>However when we get the following error:</p>
  <pre><code>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.
  </code></pre>
  <p>How can this be possible if I am able to get the token via the following?</p>
  <pre><code>AuthToken currentToken = AuthTokenAccessor.getCurrentToken();
  AuthToken xsuaaServiceToken = AuthTokenAccessor.getXsuaaServiceToken();
  </code></pre>
  <p>I have also tried to authenticate with the token passed i.e.</p>
  <pre><code>AuthTokenAccessor.executeWithAuthToken(currentToken,  () -&gt; DestinationAccessor.getDestination(Constants.DEFAULT_S4_HANA_CLOUD));
  </code></pre>
  <p>Are we missing a crucial step in the process? Has anyone encountered this issue before?</p>
  <p>How are we able to correctly pass the AuthToken to the destination?</p>
  <p>Here is a snippet of my dependencies as requested:<a href="https://pastebin.com/iweEDfyN" rel="nofollow noreferrer">https://pastebin.com/iweEDfyN</a></p>
  <p>Thanks in Advance!</p>