小编And*_*oke的帖子

Firebase Google 登录卡在 /__/auth/handler 路线上

我正在按照此处的步骤尝试将 Google 登录添加到使用的项目中。Firebase 授权。

  • 我在 iframe 中运行代码(因为它是 Airtable 应用程序)。这可能是问题所在吗?
  • 我已在 firebase 控制台中启用 Google 登录。
  • data-fetcher-dev.firebaseapp.com包含在 Firebase 授权域中。

我的代码:

firebase.initializeApp({
apiKey: 'AIzaSyCp8i_9lHCyLOREMIPSUM21342xXmb0F0Y',
authDomain: 'data-fetcher-dev.firebaseapp.com',
projectId: 'data-fetcher-dev',
});

const googleProvider = new firebase.auth.GoogleAuthProvider();

googleProvider.addScope('profile');
googleProvider.addScope('email');

...

const signInWithGoogle = async () => {
    try {
      const result = await firebase.auth().signInWithPopup(googleProvider);
      console.log('result: ', result);
    } catch (error) {
      console.log('error: ', error);
    }
  };
Run Code Online (Sandbox Code Playgroud)

signInWithGoogle当按下按钮时调用。将打开一个新选项卡,我可以选择一个 Google 帐户/登录其中一个:

在此输入图像描述

选择帐户后,我将被重定向到类似的 URL https://data-fetcher-dev.firebaseapp.com/__/auth/handler?state=LONG_TOKEN_VALUE&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&authuser=3&prompt=consent,并且该页面将永远加载

在此输入图像描述

我正在使用 firebase 托管,因此 处有一个空项目https://data-fetcher-dev.firebaseapp.com。我需要在 实现后端路由吗/__/auth/handler …

javascript oauth firebase firebase-authentication google-signin

5
推荐指数
2
解决办法
1291
查看次数