admin管理员组

文章数量:1334691

I'm using firebase for authentication purposes but i'm having some troubles setting it up

I already tried everything the tutorial said but to no success

  <body>
    <div id="firebaseui-auth-container"></div>
  </body>

  <!-- firebase -->
  <script src=".2.4/firebase-app.js"></script>

  <!-- firebaseUI -->
  <script src=".0.0/firebaseui.js"></script>
  <link
    type="text/css"
    rel="stylesheet"
    href=".0.0/firebaseui.css"
  />

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "AIzaSyBtnE9XZR_tYckh5dYlwKbFdG3Nqs7y6JI",
      authDomain: "example123-6edfb.firebaseapp",
      databaseURL: "",
      projectId: "example123-6edfb",
      storageBucket: "",
      messagingSenderId: "113254883849",
      appId: "1:113254883849:web:2e6706cd75b6bbd9"
    };

    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);

    // FirebaseUI config.
    var uiConfig = {
      signInSuccessUrl: "algo.html",
      signInOptions: [
        // Leave the lines as is for the providers you want to offer your users.
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.TwitterAuthProvider.PROVIDER_ID,
        firebase.auth.GithubAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID,
        firebase.auth.PhoneAuthProvider.PROVIDER_ID
      ],
      // tosUrl and privacyPolicyUrl accept either url string or a callback
      // function.
      // Terms of service url/callback.
      tosUrl: "<your-tos-url>",
      // Privacy policy url/callback.
      privacyPolicyUrl: function() {
        window.location.assign("<your-privacy-policy-url>");
      }
    };

    // Initialize the FirebaseUI Widget using Firebase.
    var ui = new firebaseui.auth.AuthUI(firebase.auth());
    // The start method will wait until the DOM is loaded.
    ui.start("#firebaseui-auth-container", uiConfig);
  </script>

but i'm getting this error when i access the page

(index):49 Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined at (index):49

Any Ideas?

I'm using firebase for authentication purposes but i'm having some troubles setting it up

I already tried everything the tutorial said but to no success

https://www.youtube./watch?v=hb85pYZSJaI

  <body>
    <div id="firebaseui-auth-container"></div>
  </body>

  <!-- firebase -->
  <script src="https://www.gstatic./firebasejs/6.2.4/firebase-app.js"></script>

  <!-- firebaseUI -->
  <script src="https://cdn.firebase./libs/firebaseui/4.0.0/firebaseui.js"></script>
  <link
    type="text/css"
    rel="stylesheet"
    href="https://cdn.firebase./libs/firebaseui/4.0.0/firebaseui.css"
  />

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "AIzaSyBtnE9XZR_tYckh5dYlwKbFdG3Nqs7y6JI",
      authDomain: "example123-6edfb.firebaseapp.",
      databaseURL: "https://example123-6edfb.firebaseio.",
      projectId: "example123-6edfb",
      storageBucket: "",
      messagingSenderId: "113254883849",
      appId: "1:113254883849:web:2e6706cd75b6bbd9"
    };

    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);

    // FirebaseUI config.
    var uiConfig = {
      signInSuccessUrl: "algo.html",
      signInOptions: [
        // Leave the lines as is for the providers you want to offer your users.
        firebase.auth.GoogleAuthProvider.PROVIDER_ID,
        firebase.auth.FacebookAuthProvider.PROVIDER_ID,
        firebase.auth.TwitterAuthProvider.PROVIDER_ID,
        firebase.auth.GithubAuthProvider.PROVIDER_ID,
        firebase.auth.EmailAuthProvider.PROVIDER_ID,
        firebase.auth.PhoneAuthProvider.PROVIDER_ID
      ],
      // tosUrl and privacyPolicyUrl accept either url string or a callback
      // function.
      // Terms of service url/callback.
      tosUrl: "<your-tos-url>",
      // Privacy policy url/callback.
      privacyPolicyUrl: function() {
        window.location.assign("<your-privacy-policy-url>");
      }
    };

    // Initialize the FirebaseUI Widget using Firebase.
    var ui = new firebaseui.auth.AuthUI(firebase.auth());
    // The start method will wait until the DOM is loaded.
    ui.start("#firebaseui-auth-container", uiConfig);
  </script>

but i'm getting this error when i access the page

(index):49 Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined at (index):49

Any Ideas?

Share Improve this question edited Jul 11, 2019 at 19:51 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Jul 11, 2019 at 19:11 chunichuni 1362 silver badges14 bronze badges 2
  • Are you properly filling out all the values in the firebaseConfig Object? – hewiefreeman Commented Jul 11, 2019 at 19:14
  • yes i copy and pasted what the firebase page gave to paste in my project – chuni Commented Jul 12, 2019 at 12:35
Add a ment  | 

1 Answer 1

Reset to default 8

you are missing the auth script file

add this where you are loading firebase:

 <!-- firebase -->
  <script src="https://www.gstatic./firebasejs/6.2.4/firebase-app.js"></script>
  <script src="https://www.gstatic./firebasejs/6.2.4/firebase-auth.js"></script>
  <!-- firebaseUI -->
  <script src="https://cdn.firebase./libs/firebaseui/4.0.0/firebaseui.js"></script>

If you need more information, check the docs here

本文标签: javascriptHow to fix Cannot read property 39GoogleAuthProvider39 of undefinedStack Overflow