user6039980
user6039980

Reputation: 3506

Firebase: This domain is not authorized

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

Upvotes: 76

Views: 117069

Answers (13)

user6039980
user6039980

Reputation: 3506

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.

Upvotes: 83

Oualid Sahnoun
Oualid Sahnoun

Reputation: 36

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.

Upvotes: 0

Shubham Sarda
Shubham Sarda

Reputation: 635

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.)

Upvotes: 8

nth-child
nth-child

Reputation: 550

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

Upvotes: 1

Kishore
Kishore

Reputation: 1

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.

Upvotes: 0

sloneorzeszki
sloneorzeszki

Reputation: 1524

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.

Upvotes: 1

atb00ker
atb00ker

Reputation: 1105

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

Upvotes: 6

Roberto Rodriguez
Roberto Rodriguez

Reputation: 3347

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.

Upvotes: 1

Ronnie Smith
Ronnie Smith

Reputation: 18565

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

Upvotes: 1

Suliman Farzat
Suliman Farzat

Reputation: 1260

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

Upvotes: 66

isawk
isawk

Reputation: 1057

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.

Upvotes: 16

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

Upvotes: 3

TheAppchemist
TheAppchemist

Reputation: 514

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);

Upvotes: 12

Related Questions