How can I do OAuth request by open new window, instead of redirect user from current page? How can I do OAuth request by open new window, instead of redirect user from current page? javascript javascript

How can I do OAuth request by open new window, instead of redirect user from current page?


Assuming you're opening authentication url in a pop-up using window.open(), you can access parent window by using:

window.opener

and to reload parent window (from a pop-up) use:

window.opener.location.reload();

This code should be served on url that you've set up as success callback url of oauth authorization.

In general, the flow should be:

  • open a pop-up with an authorization page (on twitter.com for example)
  • after successfull authorization twitter redirects user to url given by you (it gets opened in the very same pop-up)
  • the opener window gets reloaded (via window.opener.location.reload())
  • close the pop-up itself (using javascript is you want)