views:

195

answers:

1

I got oauth working fine with twitter in my GWT app. However, when I use Window.open() to try and do the oauth flow, get a successful oauth, and twitter redirects the newly opened window to my callback url, I have an issue.

The only way I can see to close the window is to use JSNI and call $wnd.close(). After I close the window I am using for oauth, I want to then call methods on the parent window to continue. However, since I can't figure out how to access the parent window, I don't know how to do this.

Originally I tried a GWT dialogbox which is awesome due to the modal dialog and glass background featues, but unfortunately doesn't work because when redirecting to twitter, if you are in an iframe, they kill the iframe.

I'm thinking something along the lines of keeping the window's opener object stored in a java JavaScriptObject, then using it to invoke my GWT code after I've closed the window I'm using for oauth.

Has anyone done this? What I'm trying to do is basically what tweetmeme does via non GWT javascript in it's twitter oauth.

Thanks.

+4  A: 

Window.open in Javascript returns a handle to the child window. Since GWT's Window.open does not return you this handle, why don't you use your own JSNI which does a javascript call and returns the window handle? You can then preserve this window handle in your GWT app and then use ti to close the window later passing this handle to another JSNI that just does window.close()

Ashwin Prabhu