<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article How to get a OTP from an API and use it in a Browser Monitor in Troubleshooting</title>
    <link>https://community.dynatrace.com/t5/Troubleshooting/How-to-get-a-OTP-from-an-API-and-use-it-in-a-Browser-Monitor/ta-p/239746</link>
    <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;DIV&gt;
&lt;H2 class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;Summary&lt;/H2&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;This article explains how to retrieve a &lt;STRONG&gt;One-Time Password (OTP)&lt;/STRONG&gt; from an API and use it dynamically in a &lt;STRONG&gt;Dynatrace Browser Monitor&lt;/STRONG&gt;. This approach enables synthetic monitoring of applications protected by &lt;STRONG&gt;multi-factor authentication (MFA)&lt;/STRONG&gt; by automatically requesting, storing, and inserting an OTP during the login process.&lt;/DIV&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;By integrating an API call into your Browser Monitor script, you can automate OTP-based authentication and ensure end-to-end monitoring of secure user journeys.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;H2&gt;Problem&lt;/H2&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;Many modern applications protect user logins with &lt;STRONG&gt;One-Time Password (OTP)&lt;/STRONG&gt; or &lt;STRONG&gt;Multi-Factor Authentication (MFA)&lt;/STRONG&gt; mechanisms. When creating a &lt;STRONG&gt;Dynatrace Browser Monitor&lt;/STRONG&gt;, these additional authentication steps can prevent the monitor from successfully completing the login workflow.&lt;/DIV&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;Common scenarios include:&lt;/DIV&gt;
&lt;UL&gt;
&lt;LI class="___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf"&gt;Applications that require MFA during sign-in&lt;/LI&gt;
&lt;LI class="___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf"&gt;OTP values generated by internal services and exposed through APIs&lt;/LI&gt;
&lt;LI class="___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf"&gt;Authentication workflows that require a fresh OTP for every login attempt&lt;/LI&gt;
&lt;/UL&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;Without dynamically retrieving and inserting the OTP, the Browser Monitor may fail at the authentication step because the required verification code is missing, expired, or invalid.&lt;/DIV&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;H2 class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;Pre-requisites&lt;/H2&gt;
&lt;DIV class="paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol"&gt;&lt;SPAN&gt;Before implementing the solution, make sure: &lt;/SPAN&gt;
&lt;UL class="___14cu5j8 fdgang7 f1hu3pq6 f19f4twv fuxrj8o" dir="auto"&gt;
&lt;LI value="1"&gt;You have the API endpoint that returns a valid OTP.&lt;/LI&gt;
&lt;LI value="2"&gt;Your API credentials or access token are available and working.&lt;/LI&gt;
&lt;LI value="3"&gt;The OTP is valid only for the duration required by the login step (usually a few seconds).&lt;/LI&gt;
&lt;/UL&gt;
&lt;SPAN&gt;Check if the issue matches this article by confirming: &lt;/SPAN&gt;
&lt;UL class="___14cu5j8 fdgang7 f1hu3pq6 f19f4twv fuxrj8o" dir="auto"&gt;
&lt;LI value="1"&gt;The Browser Monitor fails at the OTP input step.&lt;/LI&gt;
&lt;LI value="2"&gt;Application logs or monitor details show missing or invalid OTP value.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;H2&gt;Resolution&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;Follow these steps to configure your Browser Monitor with dynamic OTP handling:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Create the Browser monitor events up to the point where the one-time password (OTP) is needed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL dir="auto"&gt;
&lt;LI&gt;Navigate to the URL.&lt;/LI&gt;
&lt;LI&gt;login with credentials&lt;/LI&gt;
&lt;LI&gt;The OTP page appears.&lt;/LI&gt;
&lt;LI&gt;Open a page on the same domain as the API URL in a new tab if the original navigation and API domains are different. This step is only necessary if you see a CORS error when making the fetch in the next event.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;2. Add a JavaScript event, using&amp;nbsp;&lt;STRONG class="sc-bf977b27-0 hNpJEd"&gt;&lt;A href="https://docs.dynatrace.com/docs/platform-modules/digital-experience/synthetic-monitoring/browser-monitors/configure-browser-monitors#recorded-clickpath" target="_self"&gt;Add synthetic event&lt;/A&gt;,&amp;nbsp;&lt;/STRONG&gt;to fetch the OTP value and save the value. Something like the below, which stores the value in a variable called token.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;api.startAsyncSyntheticEvent();&lt;BR /&gt;fetch('&amp;lt;yoururl&amp;gt;', {&lt;BR /&gt;    method: 'POST',&lt;BR /&gt;    headers: {&lt;BR /&gt;        'content-type': 'application/json',&lt;BR /&gt;        'Access-Control-Allow-Origin': '*',&lt;BR /&gt;        'Access-Control-Allow-Headers': 'X-Requested-With'&lt;BR /&gt;    }&lt;BR /&gt;}).then(function(response) {&lt;BR /&gt;        if (!response.ok) {&lt;BR /&gt;            throw Error(response.status + ":" + response.statusText);&lt;BR /&gt;        }&lt;BR /&gt;        return response;&lt;BR /&gt;   }).then(response =&amp;gt; response.text()).then(text =&amp;gt; {&lt;BR /&gt;        try {&lt;BR /&gt;            api.info('Resp length:  ' + text.length);&lt;BR /&gt;            if (text.indexOf('code') &amp;gt;= 0) {&lt;BR /&gt;                &amp;lt;your code to retrieve token&amp;gt;&lt;BR /&gt;                api.setValue("token", token);&lt;BR /&gt;                api.finish();&lt;BR /&gt;            } else {&lt;BR /&gt;                api.fail("Invalid Response");&lt;BR /&gt;            }&lt;BR /&gt;        } catch (err) {&lt;BR /&gt;            api.fail("Failed to Execute");&lt;BR /&gt;        }&lt;BR /&gt;   }).catch(function(error) {&lt;BR /&gt;        api.fail(error); &lt;BR /&gt;   });&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;3. Add a second JavaScript event to pass the value to the OTP generation page&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;var pin = api.getValue("token");&lt;BR /&gt;document.querySelector("#PIN").value = pin;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;4. Complete any other steps needed.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;What's Next&lt;/H2&gt;
&lt;P&gt;If these steps don't help, then open a chat and provide the following:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;a link to affected monitor&lt;/LI&gt;
&lt;LI&gt;the troubleshooting steps you have already completed&lt;/LI&gt;
&lt;LI&gt;a link to this article&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN data-contrast="auto"&gt;What to read next:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN data-ccp-props="{&amp;quot;134233117&amp;quot;:false,&amp;quot;134233118&amp;quot;:false,&amp;quot;335559738&amp;quot;:299,&amp;quot;335559739&amp;quot;:299}"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;span class="lia-unicode-emoji" title=":open_book:"&gt;📖&lt;/span&gt;&amp;nbsp; &lt;A id="link_6" class="page-link lia-link-navigation lia-custom-event" style="font-family: inherit; background-color: #ffffff;" href="https://community.dynatrace.com/t5/Troubleshooting/Synthetic-Troubleshooting-Map/ta-p/250426" target="_blank" rel="noopener"&gt;Synthetic Troubleshooting Map&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":open_book:"&gt;📖&lt;/span&gt;&amp;nbsp; &lt;A id="link_6" class="page-link lia-link-navigation lia-custom-event" style="font-family: inherit; background-color: #ffffff;" href="https://community.dynatrace.com/t5/Troubleshooting/Synthetic-Browser-Monitor-Error-Codes/ta-p/198177" target="_blank" rel="noopener"&gt;Synthetic Browser Monitor Error Codes&lt;BR /&gt;&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":open_book:"&gt;📖&lt;/span&gt;&amp;nbsp; &lt;A id="link_6" class="page-link lia-link-navigation lia-custom-event" style="font-family: inherit; background-color: #ffffff;" href="https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/configure-browser-monitors" target="_blank" rel="noopener"&gt;Configure Browser Monitors&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":open_book:"&gt;📖&lt;/span&gt;&amp;nbsp; &lt;A id="link_6" class="page-link lia-link-navigation lia-custom-event" style="font-family: inherit; background-color: #ffffff;" href="https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events#javascript" target="_blank" rel="noopener"&gt;JavaScript events&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":open_book:"&gt;📖&lt;/span&gt;&amp;nbsp; &lt;A id="link_6" class="page-link lia-link-navigation lia-custom-event" style="font-family: inherit; background-color: #ffffff;" href="https://docs.dynatrace.com/docs/shortlink/synthetic-monitors" target="_blank" rel="noopener"&gt;Dynatrace Synthetic app&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 21 Aug 2026 14:07:30 GMT</pubDate>
    <dc:creator>HannahM</dc:creator>
    <dc:date>2026-08-21T14:07:30Z</dc:date>
    <item>
      <title>How to get a OTP from an API and use it in a Browser Monitor</title>
      <link>https://community.dynatrace.com/t5/Troubleshooting/How-to-get-a-OTP-from-an-API-and-use-it-in-a-Browser-Monitor/ta-p/239746</link>
      <description>&lt;P&gt;&lt;LI-TOC indent="15" liststyle="disc" maxheadinglevel="2"&gt;&lt;/LI-TOC&gt;&lt;/P&gt;
&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;*&lt;EM&gt;Use a table of contents for longer articles.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;H2&gt;Summary&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*This is a mandatory section.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Short description of which part of the Dynatrace platform the article refers to and what kind of problem it will help resolve/ task it will describe.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Problem&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*This is a mandatory section.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Provide a precise description of the problem/ task to be described. Use anonymized screenshots, and include text for&amp;nbsp;important messages, errors, or information that will help the customer find this article when searching.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Troubleshooting steps&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*This section can be omitted as necessary.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Explain what troubleshooting steps should be taken to ensure the problem matches this article.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Resolution&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*This section can be omitted for articles that guide customers on case creation.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Explain the solution or all possible solutions resulting from the troubleshooting steps.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;H2&gt;What's next&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*This is a mandatory section. Customers need a way to respond or follow up if they have questions.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Explain what to do if the article didn't help.&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;Note that there are multiple options available, including:&lt;/EM&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;Opening a chat or support case&amp;nbsp;&lt;/STRONG&gt;- be as specific as possible about the information the customer should include in the case.&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;Use the following formula and fill or change the bullet points:&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt; If this article didn't help, &lt;STRONG&gt;create a chat or open a support case&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;Mention that you reviewed this article.&lt;/LI&gt;
&lt;LI&gt;Include the following details:
&lt;UL&gt;
&lt;LI&gt;Link to XYZ&lt;/LI&gt;
&lt;LI&gt;Screenshot of XYZ&lt;/LI&gt;
&lt;LI&gt;Information about XYZ&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;&lt;STRONG&gt;Suggesting Product Idea&lt;/STRONG&gt; - encourage the customer to suggest/ vote for a Product Idea explaining their business use case.&lt;BR /&gt;&lt;/EM&gt;
&lt;DIV&gt;Please submit a Product Idea with detailed information about your request and use case in the Product Ideas forum. Our Product Management team regularly reviews these suggestions:&lt;/DIV&gt;
&lt;A href="https://community.dynatrace.com/t5/Dynatrace-product-ideas/idb-p/DynatraceProductIdeas" target="_blank" rel="noopener"&gt;https://community.dynatrace.com/t5/Dynatrace-product-ideas/idb-p/DynatraceProductIdeas&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;EM&gt;Explain this will change in the future &lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;- explain that this behavior will change in a future release. (No product idea / support case needed)&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;EM&gt;Alternatives -&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;any other actions or links to other articles that could move the customer forward.&lt;/EM&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;H2&gt;&lt;BR /&gt;Related reading&lt;/H2&gt;
&lt;P&gt;&lt;EM&gt;*Link this article to other relevant configuration or troubleshooting guides, including any applicable troubleshooting maps.&lt;BR /&gt;:open_book:&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;A href="https://community.dynatrace.com/t5/Troubleshooting/" target="_blank" rel="noopener"&gt;XXX Troubleshooting Map&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;:open_book:&amp;nbsp; Link 1&lt;/P&gt;
&lt;P&gt;:open_book:&amp;nbsp; Link 2&lt;/P&gt;
&lt;P&gt;:open_book:&amp;nbsp; Link 3&lt;/P&gt;
&lt;P&gt;:open_book:&amp;nbsp; Link 4&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Aug 2026 14:07:30 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Troubleshooting/How-to-get-a-OTP-from-an-API-and-use-it-in-a-Browser-Monitor/ta-p/239746</guid>
      <dc:creator>HannahM</dc:creator>
      <dc:date>2026-08-21T14:07:30Z</dc:date>
    </item>
  </channel>
</rss>

