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

Error in @sap-cloud-sdk/connectivity version 3.18.0 #5026

Open
BastiInnovation opened this issue Sep 25, 2024 · 0 comments
Open

Error in @sap-cloud-sdk/connectivity version 3.18.0 #5026

BastiInnovation opened this issue Sep 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@BastiInnovation
Copy link

BastiInnovation commented Sep 25, 2024

Describe the bug
After updating @sap-cloud-sdk/connectivity from version 3.17.0 to 3.18.0. The destination from getDestinationFromDestinationService() is null. In cloud foundry log i received a warning: "Cannot create cache key for client credentials token cache. The given tenant id is undefined".

To Reproduce

const getDestinationFromDestinationService = require('@sap-cloud-sdk/connectivity').getDestinationFromDestinationService;
const serviceToken = require('@sap-cloud-sdk/connectivity').serviceToken;
const getXsuaaServiceCredentials = require('@sap-cloud-sdk/connectivity/dist/scp-cf').getXsuaaServiceCredentials;
const getDestinationServiceCredentials = require('@sap-cloud-sdk/connectivity/dist/scp-cf').getDestinationServiceCredentials;
const requests = require('@sap/xssec').requests;

static async getDestination(tenant){
    return await getDestinationFromDestinationService({ 
        destinationName: 'myDestinationName',
        jwt: await this.fetchToken(tenant),
        iasToXsuaaTokenExchange: false });
  }

static async fetchToken(tenant){
    let token;
    if( getXsuaaServiceCredentials() ) {
      token = await serviceToken('xsuaa', { jwt: { iss: `https://${tenant}.localhost:8080/uaa/oauth/token` }, useCache: true });
    } else {
      token = await new Promise((resolve) => requests.requestClientCredentialsToken(tenant, getDestinationServiceCredentials(), null, (_err, tkn) => resolve(tkn)));
    }
    return token;
  }

Expected behavior
I expected to receive the destination from getDestination() because the token from fetchToken() is the right one.
I think there is a relation to 4799, but I found non solution in the related documentation.

Used Versions:
node version: v20.11.0
sap-cloud-sdk/connectivity: v3.18.0
sap-cloud-sdk/util: v3.18.0
sap/cds: v7.9.4
sap/xssec: v3.6.1

@BastiInnovation BastiInnovation added the bug Something isn't working label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant