Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firebase auth domain not authorized even after whitelisting domain

I am using Firebase Auth (firebase 4.1.3) in my Angular4 project with Google sign in enabled. While working on localhost everything works as expected. However, when deploying my app hosted on Google App Engine, authentication popup fails with the "auth/unauthorized-domain" error.

How can I whitelist my custom domain in Firebase?

Checks already done:

  1. My firebase project has billing enabled and active
  2. Google sign-in with pop-up works on localhost
  3. Google app engine domain is already whitelisted in "Authorized Domains" under Sign-In method, in Authenticacion module of Firebase console.
  4. Double checked the javascript firebase config in my angular app (I copy-pasted the snippet given by the firebase console).
  5. In the Google Cloud Console, the default web API key has no access restrictions and the OAuth client id already contains my App Engine domain in the list of "Authorized JavaScript origins" and also in the "Authorized redirect URIs" (https://console.developers.google.com/apis/credentials?project=MYPROJECT).

Some other similar SO questions refer to checking the previous things and even waiting up to 20 mins after whitelisting a new domain to allow change propagation. But none of these advices worked for me.

NOTE: Full error code

{
code: "auth/unauthorized-domain"
message: "This domain (PROJECT.appspot.com) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab."
}

Any help would be appreciated.

like image 354
Leonardo T Avatar asked Aug 23 '17 14:08

Leonardo T


2 Answers

Ok, Answering my own question. I finally found the problem: I was deploying an old version of the web app. So it will never work this way...

In case it could be useful to others, the above steps for configuring firebase Auth are correct and enough!

like image 178
Leonardo T Avatar answered Nov 16 '22 08:11

Leonardo T


I was taking over an existing project, and I got this error while deploying with the wrong environment. (the domain was correctly setup in Firebase)

ng build --prod && firebase deploy

While was deploying on my Dev Environment.

I've scripted the deployment to avoid this kind of mistake.

ng build --configuration "${ENV}" && firebase deploy

where env var is set as an argument of the script

like image 1
Thomas Avatar answered Nov 16 '22 06:11

Thomas