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?
Finally!! signIn() method uses JS Promise. So code can be used is:
Hope this will help!
In your constructor (service) or ngOnInit (for component) do the following:
Then, in your login function, call:
Was having same problem. Seems browser(s) (or at least chrome) will block any "window.open" call which it was invoked not as part of a user interaction.
Refer to here for a deeper explanation.
__
I used to have this next code inside click event listener:
Note the asynchronous way of loading 'auth2', which is how google docu says.
I changed it to:
Then, inside click event handler, we can do:
... so browser does not block google login popup
Update:
Now you need to use Firebase auth
https://firebase.google.com/docs/auth/
Answer:
For me I changed init method to have a callback function (empty one)... Here's how:
Wrong (popup blocked by browser) (no call back function):
Correct working like charm: