0

I have a windows 8 metro app that does an oauth login via iframing the login form of the remote service. I need to monitor navigation in the iframe as the final step will navigate to a url that includes oauth codes I need to read out of the url.

There are 2 parts to this question:

  1. How do I monitor navigation in the iframe.

  2. How do I get the current location of the iframe. Everything I'm trying (document.getElementById('theIframe').{src|contentWindow.location.href}) either gives the initial location or returns an Access Denied error.

3
  • Is there are reason you are not using the WebAuthenticationBroker?
    – Jeff Brand
    Aug 27, 2012 at 18:57
  • @JeffBrand-MSFT I guess I can do but it doesn't fit in well with the look and feel of the application. Is there any way to disable the requirement that the Broker urls require ssl, just for testing purposes. I'm hosting the oauth server locally right now and really don't want the hassle of installing a ssl cert on my dev box.
    – Endophage
    Aug 27, 2012 at 19:36
  • @JeffBrand-MSFT That WebAuthenticationBroker wasn't documented anywhere obvious. Would you like to add an answer with a link to the sample project and I'll accept it. I got it working.
    – Endophage
    Aug 28, 2012 at 0:10

1 Answer 1

0

As @JeffBrand-MSFT suggested, this sample may help. http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122

Some documentation that maybe helpful http://msdn.microsoft.com/en-us/library/windows/apps/windows.security.authentication.web.webauthenticationbroker

To answer your original question, you can query the .src property in the iframe to monitor the url. (e.g. var currentLocatoin = $('#iframeId').src) or you can implement postMessage protocol between your native app and the content inside of the iframe. Mircrosoft sandboxed the iframe content, thus calling $('#iframeId').contentWindow.location.href will give you Access Denied Error

2
  • I found the various attributes (src, contentWindow.location.href) never actually update such that the parent can see them, my second point in the original Q. I got this working with the WebAuthenticationBroker once I was put onto that, it just wasn't easy to find that info until pointed at it.
    – Endophage
    Dec 19, 2012 at 23:40
  • In my application where I have an iframe, I used the postMessage to query the location. But I wasn't using it for authentication.
    – louis.luo
    Dec 20, 2012 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.