google-app-enginepopuppopup-blocker

detect error: "popup_blocked_by_browser" for google auth2 in javascript


After lot of googling didn't find solution how to catch error of window popup blocker for google auth2

getting an error in console error: "popup_blocked_by_browser". all I want is to do is tell user that pop up should be enabled for auth.

samples using window.open() are not good, since they open useless window. As I see a lot of people searching for this.

Any advice?


Solution

  • Finally!! signIn() method uses JS Promise. So code can be used is:

    gapi.auth2.getAuthInstance().signIn().then(function(){}, function(error){ if (error) alert('please allow popup for this app')})
    

    Hope this will help!