I'm developing an OAuth authentication flow purely in JavaScript and I want to show the user the "grant access" window in a popup, but it gets blocked.
How can I prevent pop up windows created by either window.open
or window.showModalDialog
from being blocked by the different browsers' pop-up blockers?
from Google's oauth JavaScript API:
http://code.google.com/p/google-api-javascript-client/wiki/Authentication
See the area where it reads:
Setting up Authentication
The client's implementation of OAuth 2.0 uses a popup window to prompt the user to sign-in and approve the application. The first call to gapi.auth.authorize can trigger popup blockers, as it opens the popup window indirectly. To prevent the popup blocker from triggering on auth calls, call gapi.auth.init(callback) when the client loads. The supplied callback will be executed when the library is ready to make auth calls.
I would guess its relating to the real answer above in how it explains if there is an immediate response, it won't trip the popup alarm. The "gapi.auth.init" is making it so the api happens immediately.
Practical Application
I made an open source authentication microservice using node passport on npm and the various passport packages for each provider. I used a standard redirect approach to the 3rd party giving it a redirect URL to come back to. This was programmatic so I could have different places to redirect back to if login/signup and on particular pages.
github.com/sebringj/athu
passportjs.org
Most easiest way to get rid of this is, which worked for me very well -
Ex :
This works very well. Cheers