Showing results for 
Show  only  | Search instead for 
Did you mean: 

Missing property 'token' on type 'AbstractCredentialsResponseElement'



I tried to use credentialVaultClient to retrieve a token stored in the credentials vault. It seems like the property token is missing on the type AbstractCredentialsResponseElement. Also, I need to copy the response to get the token.


	private getToken = () => {
		const resp = credentialVaultClient.getCredentialsDetails({
			id: dynatraceConfig['API_TOKEN'][this.environmentId][this.env],
		const respCopy: any = { ...resp };
		return respCopy.token;


This is my package.json:


"dependencies": {
    "@dynatrace-sdk/app-environment": "^1.0.0",
    "@dynatrace-sdk/app-utils": "^0.2.2",
    "@dynatrace-sdk/client-classic-environment-v2": "^1.1.0",
    "@dynatrace-sdk/client-query": "1.2.0",
    "@dynatrace-sdk/error-handlers": "1.1.0",
    "@dynatrace-sdk/navigation": "1.0.0",
    "@dynatrace-sdk/user-preferences": "1.0.0",
    "@dynatrace/strato-components-preview": "0.97.1",
    "@hookform/resolvers": "^3.1.1",
    "joi": "^17.9.2",
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-hook-form": "^7.45.1",
    "react-router-dom": "^6.4.1"


Please advise. Thanks.


Dynatrace Helper
Dynatrace Helper

Hi @StephenLHChancredentialVaultClient.getCredentialsDetails is an asynchronous function, which means it returns a Promise. To properly handle this, you should use async/await, something like this should work:


import {
} from "@dynatrace-sdk/client-classic-environment-v2";


private async getToken = () => {
  const resp = await credentialVaultClient.getCredentialsDetails({
    id: dynatraceConfig['API_TOKEN'][this.environmentId][this.env],
  }) as CredentialsDetailsTokenResponseElement;

  return resp.token;


Notice the keywords async in the function declaration and await right before the call to the credentials vault. Besides that, notice that I added a type assertion as CredentialsDetailsTokenResponseElement, which allows you to properly access resp.token. The reason for this is that depending on the type of the credential, the response will be of a concrete type or another (instead of just AbstractCredentialsResponseElement), containing different sets of fields. You can see all the different types in the SDK reference in the Dynatrace Developer portal.

Some additional resources:

Featured Posts