Flutter Web发布后调用Firebase Auth的signInWithPopup()出现UnimplementedError问题求助
Flutter Web发布后调用Firebase Auth的signInWithPopup()出现UnimplementedError问题求助
大家好,我最近碰到个特别头疼的问题:本地localhost跑Flutter Web项目时,调用FirebaseAuth.instance.signInWithPopup(GoogleAuthProvider())能正常完成谷歌登录,但把项目部署到线上网站后,这个功能直接报错UnimplementedError了,完全用不了。
我已经折腾了好一阵,做了不少配置排查,还是没搞定,想请各位大佬帮忙看看哪里出了问题:
已完成的配置步骤
1. index.html中的Firebase SDK引入
我在项目根目录的index.html里已经正确引入了Web版的Firebase SDK:
<script type="module"> // Import the functions you need from the SDKs you need import { initializeApp } from "https://www.gstatic.com/firebasejs/11.6.1/firebase-app.js"; // TODO: Add SDKs for Firebase products that you want to use // Your web app's Firebase configuration const firebaseConfig = // 从Firebase控制台复制的对应配置; // Initialize Firebase const app = initializeApp(firebaseConfig); </script>
2. main.dart中的Firebase初始化
在main.dart里也针对Web和其他平台做了差异化初始化:
await Firebase.initializeApp( name: kIsWeb ? null : 'my_app', options: DefaultFirebaseOptions.currentPlatform, );
3. Firebase控制台的授权域名配置
已经在Firebase控制台的Authentication -> 设置 -> 授权域名里添加了我的线上网站域名,确认域名是在授权列表里的。
4. 当前使用的依赖和Flutter版本
- 依赖版本:
firebase_core: ^3.13.0firebase_auth: ^5.5.3
- Flutter版本:3.27.4
有没有朋友遇到过类似的情况?或者能帮我排查下可能遗漏的配置点?麻烦各位了!
内容来源于stack exchange
相关产品推荐
相关产品推荐

