未捕获的FirebaseError:Firebase:需要提供选项,当不被部署到托管通过源.(应用程序/无选项).在纯html文件

ddrv8njm  于 2023-04-22  发布在  其他
关注(0)|答案(1)|浏览(89)

我试图实现一个基本的谷歌登录在一个简单的html页面,但由于某种原因,它将无法工作给我的标题中的错误,这只是基本的登录与弹出功能,你可以找到的文件中的firebase,我有一个按钮
<button class="w-100 btn btn-lg btn-success" id="g_sign" onclick="signInWithPopup">Sign in With Google</button>,它是一个基本的引导按钮,带有一个onclick属性,用于调用signinwithpopup

const auth = getAuth();
  signInWithPopup(auth, provider)
    .then((result) => {
      // This gives you a Google Access Token. You can use it to access the Google API.
      const credential = GoogleAuthProvider.credentialFromResult(result);
      const token = credential.accessToken;
      // The signed-in user info.
      const user = result.user;
      // IdP data available using getAdditionalUserInfo(result)
      // ...
    }).catch((error) => {
      // Handle Errors here.
      const errorCode = error.code;
      const errorMessage = error.message;
      // The email of the user's account used.
      const email = error.customData.email;
      // The AuthCredential type that was used.
      const credential = GoogleAuthProvider.credentialFromError(error);
      // ...
    });

我试着在auth常量旁边添加const应用程序,但没有任何效果,希望任何人都可以帮助!const auth = getAuth(app);
我尝试添加在谷歌身份验证提供商使用firebase身份验证,所以我按照文档的指示,并期望看到一个简单的弹出窗口,要求我选择哪个谷歌帐户我想使用,它没有这样做,它抛出了一个错误,在控制台,我也看了其他时间乡亲在这里问的问题,没有一个解决方案在这里似乎工作

a8jjtwal

a8jjtwal1#

我想,这是因为你使用的是onclick,而不是大写的onClick。

<button class="w-100 btn btn-lg btn-success" id="g_sign" onClick="signInWithPopup">Sign in With Google</button>

相关问题