# Missing property 'token' on type 'AbstractCredentialsResponseElement'

**URL:** <https://community.dynatrace.com/t/missing-property-token-on-type-abstractcredentialsresponseelement/40510>\
**Category:** Developer Q&A Forum\
**Tags:** credential-vault, custom-app, coding-assistance\
**Created:** [July 4, 2023, 3:50pm UTC](https://community.dynatrace.com/t/missing-property-token-on-type-abstractcredentialsresponseelement/40510 "2023-07-04T15:50:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StephenLHChan](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@StephenLHChan](https://community.dynatrace.com/u/StephenLHChan)\
**Post date:** [July 4, 2023, 3:50pm UTC](https://community.dynatrace.com/t/missing-property-token-on-type-abstractcredentialsresponseelement/40510/1 "2023-07-04T15:50:20Z")

</div>

Hey,

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.

```javascript
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`:

```markup
"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.

---

<div class="post-metadata">

**Author:** ![educampver](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/educampver/32/29917_2.png) [@educampver](https://community.dynatrace.com/u/educampver)\
**Post date:** [July 4, 2023, 4:46pm UTC](https://community.dynatrace.com/t/missing-property-token-on-type-abstractcredentialsresponseelement/40510/2 "2023-07-04T16:46:52Z")

</div>

Hi&nbsp;[@StephenLHChan](https://community.dynatrace.com/user/59527),&nbsp;`credentialVaultClient.getCredentialsDetails`&nbsp;is an asynchronous function, which means it returns a `Promise`. To properly handle this, you should use `async/await`, something like this should work:

```javascript
import {
  CredentialsDetailsTokenResponseElement,
  credentialVaultClient,
} 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&nbsp;`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&nbsp;`AbstractCredentialsResponseElement`), containing different sets of fields. You can see all the different types&nbsp;[in the SDK reference](https://developer.dynatrace.com/reference/sdks/client-classic-environment-v2/#abstractcredentialsresponseelementtype)&nbsp;in the Dynatrace Developer portal.

Some additional resources:

- Promises:&nbsp;[Promise - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
- async/await:&nbsp;[async function - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
- Type assertions:&nbsp;[Documentation - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions)

---

<div class="post-metadata">

**Author:** ![MarwanC](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marwanc/32/34480_2.png) [@MarwanC](https://community.dynatrace.com/u/MarwanC)\
**Post date:** [July 18, 2026, 4:52pm UTC](https://community.dynatrace.com/t/missing-property-token-on-type-abstractcredentialsresponseelement/40510/3 "2026-07-18T16:52:43Z")

</div>

We still experience the same issue, the token is always returning undefined, please find enclose code and results, I appreciate your support to resolve this issue:

CODE:

const response = await credentialVaultClient.getCredentials

(

{

id: “CREDENTIALS\_VAULT-1485306F4C9844D0”

}

) as CredentialsDetailsTokenResponseElement;

console.log("token = ", response.token);

console.log("summary= ",response.credentialUsageSummary);

console.log("description= ",response.description);

console.log("externalVault = ",response.externalVault);

console.log("id = ",[response.id](http://response.id/));

console.log("name = ",&nbsp;[response.name](http://response.name/));

console.log(“owner=”,response.owner);

console.log("ownerAccessOnly = ", response.ownerAccessOnly);

console.log("scope = ",response.scope);

console.log("type = ", response.type);

console.log(Object.keys(response));

console.log(JSON.stringify(response, null, 2));

RESULTS:

token = undefined

summary= []

description= Rotating token

externalVault = null

id = CREDENTIALS\_VAULT-1485306F4C9844D0

name = [t-d] DT-A Interface Rotating Token

owner=&nbsp;[mc@me.com](mailto:mc@me.com)

ownerAccessOnly = false

scope = APP\_ENGINE

type = TOKEN

[

“name”,

“id”,

“description”,

“owner”,

“ownerAccessOnly”,

“scope”,

“externalVault”,

“credentialUsageSummary”,

“scopes”,

“allowedEntities”,

“allowContextlessRequests”,

“type”

]

{

“name”: “[t-d] DT-A Interface Rotating Token”,

“id”: “CREDENTIALS\_VAULT-1485306F4C9844D0”,

“description”: “Rotating token”,

“owner”: “[mc@me.com](mailto:mc@me.com)”,

“ownerAccessOnly”: false,

“scope”: “APP\_ENGINE”,

“externalVault”: null,

“credentialUsageSummary”: [],

“scopes”: [

“APP\_ENGINE”

],

“allowedEntities”: [],

“allowContextlessRequests”: false,

“type”: “TOKEN”

}
