Hello All,
I notice you can see the value of a token when used in Javascript, I assume that this is inherent to the used implementation? Or will there be an improvement?
KR Henk
Hi! In the screenshot, youâre seeing the Result tab of a ârun_javascriptâ task. Most likely, the token is returned as part of this task. You can investigate and change this by editing the Workflow, and looking at the âRun JavaScriptâ task in question, which probably looks something like this:
// optional import of sdk modules
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
// your code goes here
const token = "1234";
const scope = "SCOPE";
// do something
return { token: token, scope: scope };
}
edit: now if youâre asking whether you can mask this token, thatâs a no for now. What you could however do instead is store the token using secrets in App-Settings or Dynatrace Credential Vault.
Hi Christian,
Sorry, it is returned by below code in the task:
tokenCredentials = await credentialVaultClient.getCredentialsDetails({
id: âCREDENTIALS_VAULT-04B79924E62A26F3â,
So I was thinking it is the real token value
KR Henk
Now I see
The Run JavaScript task is doing exactly what you tell it to do, which, in this case, is returning the full response of getCredentialsDetails from credentialVaultClient.
I suppose you want to use the token returned in a follow-up task?
Yes, thatâs all correct. Donât return the token. Support for using credentials/secrets in a secure way is on the roadmap, as far as I know. For the time being,
For the time being, you can use fetch in the Run JavaScript action like this:
const token = await credentialVaultClient.getCredentialsDetails({
id: "CREDENTIALS_VAULT-ABCD1234",
}).then((credentials)=> credentials.token);
const url = "https://....";
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`
}
).then(response => response.json());
Cool thx Christain!
Hi, is this solution also valid for Managed?
Hi!
No, itâs only for SaaS, with DPS.