0

We allow external OAuth using PHP APIs to several social networks. When the user choose external authentication, a new window (popup) is opened, where the application asks authorization. Then, still in the popup, the user is redirected using the callback url given to the external application. The callback script performs various tasks (login, checks, synchronization,...) that may requires some time, before the popup is closed, and the mother page updated. While those task are performed, the popup is just blank.

What I would like is to display a "please wait..." message on the popup when the callback url is called. One solution is that the popup just display the message and pass an AJAX, but as I don't know the parameters of the callback (that depends on the external application), I would like to avoid this. Is there any way to do it with only one PHP script ?

Jean-Marc Dormoy
  • 129
  • 1
  • 2
  • 9
  • Is the callback forward to your site? – Dmitriy Sushko Nov 26 '12 at 09:47
  • Yes. when the user click on the 'log in with...', it calls a script named 'bzkExternalOAuth.php, where the right API is loaded (Fb, linkedin, google,...). If we use for instance FB, the page is then redirected to FB, and at the end, when the user authorized my site to his FB, it callbacks the same 'bzkExternalOAuth.php'. – Jean-Marc Dormoy Nov 26 '12 at 10:10

2 Answers2

0

You can perform the authorization in an iFrame (will require additional work to sync the iframe with the popup to get to the behaviour you have in mind) and design the window as you desire.

You can also just set the title.

kamasheto
  • 1,020
  • 6
  • 12
  • I believe I read somewhere that using an iframe was not a good practice in that case (I can't remember which application's documentation it was) – Jean-Marc Dormoy Nov 26 '12 at 10:00
  • I beg your pardon. You cannot change even the title if you don't have control of the "loaded" page (the popped up, which I suggested you add the iframe to.) The callback URL for your auth service controls all of what the user sees after you open that popup with the designated URL. If you don't fancy using the iframe, you're stuck with not being able to do anything about it. – kamasheto Nov 26 '12 at 10:04
  • I can't find the reference to the recommendation of not using an iframe. So I will investigate in this direction again. By additional work, do you mean that I have to set up a periodical observer to check the content of the iframe (if for instance the page is blank, then I "mask" the iframe with some design in the popup containing the iframe) ? – Jean-Marc Dormoy Nov 26 '12 at 10:25
  • Nope. Something along the lines of making sure the auth service redirects to a page of yours that contains JS code that treats your parent popup. – kamasheto Nov 26 '12 at 11:55
0

As the service will return you to your server - you can try next: 1. Set transfer encoding to chunked. 2. Echo javascript document.write with loader img. 3. Do your processing. 4. Close the window after processing ends.

Dmitriy Sushko
  • 242
  • 1
  • 6