首页 > 解决方案 > Firebase 身份验证网络未登录

问题描述

我是flutter web的新手,我正在研究一个在android上运行良好的项目

问题是当我部署到 Firebase 托管并单击 google 登录按钮时。弹出窗口显示,我可以登录,但是当它弹出时,我的应用程序没有收到 FirebaseAuth.User 对象,即使我在浏览器的控制台中评估 firebase.auth().currentUser 表达式,它也保持为空

我的 index.html 文件:

<html>
<head>
  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">
  <meta name="google-signin-client_id" content="<my client id>.apps.googleusercontent.com">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="ChurchData">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png"/>

  <title>App</title>
  <link rel="manifest" href="manifest.json">
</head>
<body>
  <script src="https://apis.google.com/js/platform.js"></script>

  <script src="/__/firebase/7.24.0/firebase-app.js"></script>
  <script src="/__/firebase/7.24.0/firebase-analytics.js"></script>
  <script src="/__/firebase/7.24.0/firebase-auth.js"></script>
  <script src="/__/firebase/7.24.0/firebase-firestore.js"></script>
  <script src="/__/firebase/7.24.0/firebase-functions.js"></script>
  <script src="/__/firebase/7.24.0/firebase-messaging.js"></script>
  <script src="/__/firebase/7.24.0/firebase-storage.js"></script>
  <script src="/__/firebase/7.24.0/firebase-database.js"></script>
  <script src="/__/firebase/7.24.0/firebase-remote-config.js"></script>

  <!-- Load the Firebase SDKs before loading this file -->
  <script src="/__/firebase/init.js"></script>
  
  <script src="main.dart.js" type="application/javascript"></script>
</body>
</html>

来自 Chrome 的屏幕截图 来自 Chrome 的控制台日志

火狐的截图 来自 Firefox 的控制台日志

标签: firebasedartfirebase-authenticationfirebase-hostingflutter-web

解决方案


推荐阅读