title: Flutter web event listener on other windows
body: <p>I have a flutter web application, Im trying to implement Okta oauth2 but whenever I call the url that I manage to create with some params using DIO package I end up with having html response instead of the actual response.</p>
  <p>The endpoint I'm calling looks like this:</p>
  <blockquote>
  <p><a href="https://dev-xxxxxxxx.okta.com/oauth2/default/v1/authorize?response_type=code&amp;scope=openid+profile+offline_access&amp;client_id=xxxxxxxxxxxxxxxxxxxx&amp;redirect_uri=http://localhost:8080/authorization-code/callback&amp;code_challenge_method=S256&amp;code_challenge=Wag0u2fyeYWJHy_baK-XbMWO9H2xwUBii7R4Nvj761Y&amp;sessionToken=20111jWBb2P2BoPIL-Atd0pk5QDImstT7EmYULPFMg2GoCGPgOrxKFl&amp;state=X7hih1mUow&amp;nonce=lSfF1CxmmR" rel="nofollow noreferrer">https://dev-xxxxxxxx.okta.com/oauth2/default/v1/authorize?response_type=code&amp;scope=openid+profile+offline_access&amp;client_id=xxxxxxxxxxxxxxxxxxxx&amp;redirect_uri=http://localhost:8080/authorization-code/callback&amp;code_challenge_method=S256&amp;code_challenge=Wag0u2fyeYWJHy_baK-XbMWO9H2xwUBii7R4Nvj761Y&amp;sessionToken=20111jWBb2P2BoPIL-Atd0pk5QDImstT7EmYULPFMg2GoCGPgOrxKFl&amp;state=X7hih1mUow&amp;nonce=lSfF1CxmmR</a></p>
  </blockquote>
  <p>Whenever I call this url it shall be redirected to another url such as:</p>
  <blockquote>
  <p>http://localhost:8080/authorization-code/callback?code=TCifQEab0a6HwEGeWQXlDQhPm22RlyemvO5GbipASEU&amp;state=YLi4I2P4qd</p>
  </blockquote>
  <p>So the main point using DIO is that its returning the response of the second url which is an html flutter content.
  It can be solved if DIO don't follow the redirection and give status code 302 but its not doing that.</p>
  <p>Currently I'm trying different approach, I'm trying to open the url in a new window which immediately change to the second url.</p>
  <p>My problem is how should I get the code from the second url and the cookies that the second url provide from the new opened window.</p>
  <pre><code>final html.WindowBase newWindow = html.window.open(url, &quot;callback&quot;);
  </code></pre>
  <p>so at least how can I get the href from the newly opened window knowing that it changes after a while into the the flutter correct rout that I sat up.</p>
  <p>Knowing that <code>newWidnow.location.href</code> is write only.</p>