Firebase signInWithPopup gives auth/popup-blocked when used via built-in browser in mobile device

Hannu Hytönen picture Hannu Hytönen · Oct 6, 2016 · Viewed 9.7k times · Source

Problem: When used via 3rd-party app built-in browser (e.g. LINE, Twitter or Facebook messenger), the signInWithPopup returns auth/popup-blocked. The explanation by Firebase docs is:

  • auth/popup-blocked: Thrown if the popup was blocked by the browser, typically when this operation is triggered outside of a click handler.

Typical sequence triggering this error is: Link of my web app is sent to LINE, Twitter or Facebook messenger. When user uses mobile device and opens that link in those apps, their built-in browser is opened. Calling signInWithPopup then returns the error. The behavior is slightly different in iOS and Android but at least iOS/LINE combination results the error.

I am using Angular and building a web app. The error message is Unable to establish a connection with the popup. It may have been blocked by the browser. which comes from the firebase.js - not my own text.

When used in a normal browser, the signup works just fine.

Any ideas why the built-in browsers and signInWithPopup do not work together?

Answer

Zdeněk Mlčoch picture Zdeněk Mlčoch · Jan 4, 2018

Firebase authentication should start with some user interaction, such as click on button. This solved the problem for me.