15 Jul 2026
10:02 AM
- last edited on
16 Jul 2026
07:28 AM
by
MaciejNeumann
Hi,
We're trying to build asynthetic browser test against a site that requires OTP.
As there is no direct API to get the OTP data from the provider we need to bypass it so we've created a "back door" workflow to extract it and generate a business event that will store the result. we now in the stage that we need to query it using DQL from the script but facing CORS error as the Dynatrace domain is different than the tested site.
we already know the great article from @HannahM however the current issue is how to avoid the CORS error when accessing the platform without signing in to the platform itself (as accessing the domain itself directly goes to the login page).
Any ideas?
Gil.
Solved! Go to Solution.
16 Jul 2026 12:57 PM
Does it matter that you only go to the login page? You could ignore the 401 error, if that's causing a failure, or is it that the login page is another domain so doesn't help?
22 Jul 2026 11:53 AM
Hi @HannahM
It seemed like it was not enough but found out there was another issue. we're testing it right now. will update.
Gil.
23 Jul 2026 10:11 AM
Hi @HannahM ,
So I have the following browser test js node:
api.startAsyncSyntheticEvent();
const url = 'https://TENANTURL.apps.dynatrace.com/platform/storage/query/v1/query:execute';
const payload = {
"query": "fetch logs, from:now()-10m",
"requestTimeoutMilliseconds": 10000
};
fetch(url, {
method: 'POST',
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer TOKEN'
},
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.state && data.state !== 'SUCCEEDED') {
api.fail("Query not complete inline, state: " + data.state);
return;
}
api.info("GIL: records = " + (data.result ? data.result.records.length : 0));
api.finish();
})
.catch(error => {
api.fail("GIL: fetch failed: " + error.message);
});It runs after I navigate to my tenant url and being redirected to the sso page.
The fetch itself fails at the end and the message is plain "fetch failed". we've even changed the original website to another one. any thoughts? (I think this discussion is important to many use cases hence this is not directly also managed in a ticket - let me know if only a summary should be done here)
23 Jul 2026 07:30 PM
if I understood correctly, you have a Workflow that retrieve the OTP and stores as business events. And now, you are using the synthetic step to query this value to use it as authentication... right?
Why not store the OTP in a credential vault instead, that can be used natively by synthetics?
26 Jul 2026 06:55 AM
I should have thought of it myself!! thanks @dannemca
28 Jul 2026 02:17 PM
That's what community is for!!!
17 Sep 2026 11:47 AM
@dannemca had to remove teh solution as it seems that the credentials vault is loaded when the test is initiated and is not being refreshed/online accessed for the latest data. This means that updating the vault in the background will only be effective for the next run.
We're back at square one of how to pass the OTP value to the test. API calls to the grail events (using the apps host) are getting the CORS errors. we're looking into classic API's which are currently working but this is not a long term solution.
@HannahM any ideas as well?
Gil.
17 Sep 2026 12:50 PM
While it may seem like a roundabout path , I suugest a workflow
- get the credential
- update the vault
- On demand monitor executions API to run the synthetic test.
17 Sep 2026 01:07 PM
Yep, let the workflow orchestrate the execution.
17 Sep 2026 01:08 PM
Hi @PacoPorro ,
The thing is that the synthetic test that needs to test the whole screen is now in the middle of its run. starting a new one will generate a new OTP.
18 Sep 2026 03:00 PM
I got it now, you need to start the Browser to navigate till the 2FA page, to get the OTP screen...
How are you retrieving the OTP code, since not thru API? What are the steps you need to execute to retrieve?
Featured Posts