Related question: OAuth (Instagram) without refresh
The Situation
Instagram expects a full redirect for authentication, and then they'll redirect back. I want it to work with a popup.
Possible Solution
Open the page in a popup:
var authWindow = window.open(instagramUrl, 'authWindow');
Then I'll have instagram redirect to a page that closes itself:
<script>window.close()</script>
The Problem
I can't figure out how to find out when the window is closed. The following both don't work:
authWindow.onbeforeunload = function() {
window.opener.console.log('Closing popup!');
};
function logClose(cnsl) { cnsl.log('Closing popup!'); }
var callback = _.bind(logClose, window, console);
$(authWindow.document).click(callback);
Alternative suggestions are very welcome!