71

I imported Firebase JS v3 API and used to initialize Firebase using:

firebase.initializeApp(config);

However the app failed to load correctly via web browser on localhost, resulting in the following error:

Error: This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

firebase.js:71:1333

0

13 Answers 13

72

I solved the problem by adding the localhost domain to OAuth redirect domains (within SETUP SIGN IN METHOD on the Auth tab of Firebase console).

Updated: Aug 14 2023 - Now the Authorized domains section is moved to settings on the Authentication tab of Firebase console.

8
  • 8
    Ohhh they moved this setting into the "Sign in method" subsection of the "Auth" section. Thanks! May 21, 2016 at 22:15
  • Does it work instantly? I am using a fake local domain set up in my hosts file like myapp.localdevmachine.com. I added it with and without the subdomain part to the firebase console in the OAuth redirect domains but I still get the Unauthorized Request Origin error in the popup. It doesn't matter which provider I use they all come back to that error. I set it up about 1 hour ago and it still fails. I have also localhost, and 127.0.0.1 added to the domains. May 26, 2016 at 0:16
  • @JavierLerones If have you made all the required steps (firebase.google.com/support/guides/firebase-web) for upgrading to the new Google API, then yes it should work. May 26, 2016 at 14:24
  • what means "using localhost instead of 127.0.0.1 inside a different web browser"? how it relates to ionic app configuration?
    – ciekawy
    Jun 30, 2016 at 17:25
  • 1
    Ah so it's not about real device... I've never experienced the problem locally and thought your issue was concerning device/simulator
    – ciekawy
    Jul 11, 2016 at 8:38
61

in firebase console Auth --> Authorised domains

enter image description here


must equal (in Google cloud console -- > API & Services --> credentials ) :

enter image description here


must equal (in api config) :

enter image description here

14

Solution which worked for me after trying out all the options on the listed above and on other sites regarding using FireBase oAuth was the following:

  1. login at https://console.cloud.google.com
  2. Go to APIs & Services > Credentials

enter image description here

Once here, locate API Key you are using in your app that connects to FireBase

  1. Now add your custom domain to HTTP Referrers

enter image description here

enter image description here

For android or ios or having your application on all three mediums, you will need to create API keys per medium.

2
  • 2
    Additional fixes for some here github.com/angular/angularfire2/issues/1444, it appears that for each domain added to FireBase Security Auth Section must also manually get added to Google Console APIs and Services
    – isawk
    Jan 28, 2018 at 4:09
  • My man! Thanks so much. This is what I was looking for. Jun 20, 2021 at 10:57
12

Make sure the "authDomain" in your config matches the one in your firebase console. If you're running the app on localhost, make sure it's set to localhost and localhost exists on your firebase console.

Auth -> Sign In Method -> OAuth redirect domains

var config = {
    apiKey: "...",
    authDomain: "...", // this should match the one on your firebase console
    databaseURL: "...",
    storageBucket: "",
};
firebase.initializeApp(config);
2
  • 1
    Mine matches, yet I still get the error: Uncaught Error: An internal error has occurred.
    – KhoPhi
    Jun 10, 2016 at 20:43
  • I traced down the error message down to the point that, my api key expired was the culprit. I have no idea why it expired. But got it resolved.
    – KhoPhi
    Jun 12, 2016 at 14:32
7

Firebase now has localhost as Authorized domains by default but if you are facing this for a custom domain, here is a quick solution.

  • Go to Google console Authentication tab > Settings > Authorized domains
  • Add your domain

enter image description here

(PS - About version, I'm using Firebase 9.9.3 on React.)

0
6

Firebase Users

For me the source of the error was that the domain was not added in the firebase console. Here is an image in the firebase console to add the custom domain for your website: firebase console

2
  • 1
    how to add localhost:3000 to auth domain
    – skyshine
    Sep 26, 2020 at 8:48
  • @skyshine Click add domain and type localhost without port number if it's not already in the list. :-)
    – atb00ker
    Sep 26, 2020 at 12:07
3

Problem Authorised domain Firebase Locahost OAUTH2

If you are using Google Chrome you can see a problem with the Identity Toolkit API DISABLE. You need to enabled this API on the google cloud project to get OAUTH servcies in Firebase project.

https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=project-id

1

Not really specific to Android, but check the address in your actionCodeSettings.

actionCodeSettings.url must be correct and whitelisted.

Authenticate with Firebase Using Email Link in JavaScript

1

For those having this issue in Heroku:

Make sure you keep the authDomain property with the same value you got from Firebase.

DO NOT change this to the current Heroku domain.

1
  • 2
    would you please explain or give an example. I’m facing the same problem with Heroku . Jun 5, 2021 at 12:53
1

None of the above answers worked for me, as I already had localhost in Authorized domains list. For me the problem was incorrect API key, I must have somehow deleted one of the characters from it. I got a more descriptive (or rather - not misleading) error message when I changed to signInWithPopup to signInWithRedirect. Possibly the same problem might happen when the API key is expired.

1

None of the above solutions worked for me but this did.

  1. Go to Google console Authentication tab > Sign In Method > Authorized Domains
  2. Add 127.0.0.1

localhost was already in my Authorized Domains but in my case I needed to add 127.0.0.1 as well

1
  • 1
    didnt work for me
    – ykonda
    Mar 16 at 18:08
0

The important point is.. you must add the yourprojectid.firebaseapp.com domain to the authorized domains.. not your real domain name. That worked for me.

0

I got this problem also and the domain was like this: 127.0.0.1:5173/ I just turned it into: localhost:5173 and it ran without a problem.

Not the answer you're looking for? Browse other questions tagged or ask your own question.