Confusing Auth domain setting in Firebase

12,313

Firebase console > Authentication > Sign in methods > Auth domains

This one is used to be able to use Firebase-authentication in your project.

Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.

more info here: https://firebase.google.com/docs/auth/

AuthDomain property of the Firebase config object

this one is used when initializing your code:

var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
}; 

more info here: https://firebase.google.com/docs/web/setup

developers.google.com > Credentials > API Keys > Key restriction

This one is used to generate the API key, that you will use in your project and add it in the code above.

All 3 can be needed, but all 3 have different purposes.

Share:
12,313

Related videos on Youtube

coder
Author by

coder

Updated on June 04, 2022

Comments

  • coder
    coder about 2 years

    There seem to be multiple places to set the auth domain in a Firebase app.

    1. Firebase console > Authentication > Sign in methods > Auth domains

    2. AuthDomain property of the Firebase config object

    3. developers.google.com > Credentials > API Keys > Key restriction

    In a production app, do we have to set auth domain in all these places? Does the setting of auth domain in these different places actually have different purposes?

  • coder
    coder over 6 years
    What are the 3 different purposes?
  • Peter Haddad
    Peter Haddad over 6 years
    as I said in the answer.. the first one is used to authentication on sign up, if you want to authenticate users.. The second you have to add it in initialization..third one api key is for security. Those are their purposes @coder
  • coder
    coder over 6 years
    How to provide multiple auth domains in the config object?
  • mesqueeb
    mesqueeb over 5 years
    @PeterHaddad I would love to know more. The 2nd one doesn't have its purpose explained in your answer and the third one is reaaaly vague. Consider editing your answer so you can help more people.