网站案例展示分类dedecms做网站教程

张小明 2026/1/9 0:55:14
网站案例展示分类,dedecms做网站教程,旅游网站开发设计文档,网站链接失效怎么做Firebase提供了一套SDK用于抹平不用平台鉴权的差异性#xff0c;为了方便使用#xff0c;将基于firebase_auth、google_sign_in、sign_in_with_apple的依赖封装一套登录统一的功能集成。鉴权后将会获取idToken#xff0c;该数据需要传给服务器进行校验。步骤#xff1a;1.定…Firebase提供了一套SDK用于抹平不用平台鉴权的差异性为了方便使用将基于firebase_auth、google_sign_in、sign_in_with_apple的依赖封装一套登录统一的功能集成。鉴权后将会获取idToken该数据需要传给服务器进行校验。步骤1.定义模块最终返回的数据结构class FirebaseAuthInfo { String? idToken; String? providerId; FirebaseAuthInfo({this.idToken, this.providerId}); Map toJson() { return {idToken: idToken, providerId: providerId}; } }2. 定义工具类提供login和logout方法enum LoginType { google, apple, phone, email } class LoginMethod { late LoginType loginType; factory LoginMethod(LoginType loginType) LoginMethod._(loginType); LoginMethod._(this.loginType) { switch (loginType) { case LoginType.google: break; case LoginType.apple: break; case LoginType.phone: break; case LoginType.email: break; } } Future login() async { switch (loginType) { case LoginType.google: return await _googleSign(); case LoginType.apple: return await _appleSign(); case LoginType.phone: return; case LoginType.email: return; } } void logout() { switch (loginType) { case LoginType.google: _googleOut(); break; case LoginType.apple: break; case LoginType.phone: break; case LoginType.email: break; } } }3. 基于Firebase Email的鉴权方法该方法调用时Android和IOS需要配置对应SchemeUrl通过Applink才能实现FutureFirebaseAuthInfo? verifyEmail(String email, Uri uri) async { if (FirebaseAuth.instance.isSignInWithEmailLink(uri.toString())) { try { final firebaseAuth await FirebaseAuth.instance .signInWithEmailLink(email: email, emailLink: uri.toString()); var idToken await firebaseAuth.user?.getIdToken(); return Future.value(FirebaseAuthInfo( idToken: idToken, providerId: firebaseAuth.credential?.providerId)); } catch (error) { print(Error signing in with email link.); } return null; } else { return null; } }4. 基于Firebase Phone的鉴权方法验证码条数需要Firebase console中配置FutureFirebaseAuthInfo? phoneSign(String code, String phone) async { CompleterFirebaseAuthInfo? completer Completer(); await FirebaseAuth.instance.verifyPhoneNumber( phoneNumber: $code $phone, verificationCompleted: (PhoneAuthCredential credential) async { final firebaseAuth await FirebaseAuth.instance.signInWithCredential(credential); var idToken await firebaseAuth.user?.getIdToken(); if (!completer.isCompleted) { completer.complete(FirebaseAuthInfo( idToken: idToken, providerId: firebaseAuth.credential?.providerId)); } }, verificationFailed: (FirebaseAuthException e) { if (!completer.isCompleted) { completer.complete(null); } }, codeSent: (String verificationId, int? resendToken) {}, codeAutoRetrievalTimeout: (String verificationId) { if (!completer.isCompleted) { completer.complete(null); } }, ); return completer.future; }5. 基于Google Account的鉴权方法获取账户信息的作用域请查询官方文档如需要每次登录都可以选择指定的google账号的动作需要登录前先登出否则本地有缓存下次调用将直接复用上一次的账号信息。void _googleOut() { try { var googleSignIn GoogleSignIn( scopes: String[ https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile ], ); googleSignIn.signOut(); } catch (e) {} } FutureFirebaseAuthInfo? _googleSign() async { try { var googleSignIn GoogleSignIn( scopes: String[ https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile ], ); await googleSignIn.signOut(); var googleAccountInfo await googleSignIn.signIn(); var googleAuth await googleAccountInfo?.authentication; if (googleAuth ! null) { var firebaseAuth await FirebaseAuth.instance .signInWithCredential(GoogleAuthProvider.credential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, )); var idToken await firebaseAuth.user?.getIdToken(); return FirebaseAuthInfo( idToken: idToken, providerId: firebaseAuth.credential?.providerId); } else { return Future.value(); } } catch (e) { debugPrint(Auth error !:${e.toString()}); } return null; } }6. 基于Apple Account的鉴权方法FutureFirebaseAuthInfo? _appleSign() async { try { final appleIdCredential await SignInWithApple.getAppleIDCredential( scopes: [ AppleIDAuthorizationScopes.email, ], ); final oAuthProvider OAuthProvider(apple.com); final credential oAuthProvider.credential( idToken: appleIdCredential.identityToken, accessToken: appleIdCredential.authorizationCode, ); var identify await FirebaseAuth.instance.signInWithCredential(credential); var idToken await identify.user?.getIdToken(); return FirebaseAuthInfo(idToken: idToken, providerId: apple.com); } catch (e) { debugPrint(Auth error !:${e.toString()}); } return null; }
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

建设网站公司兴田德润i优惠吗外贸整合推广

开源TTS新突破:EmotiVoice实现多情感语音合成 在虚拟主播的直播间里,一句“太开心了!”如果只是机械地读出,观众很难共情;而在有声书中,角色悲伤独白若语调平淡,故事感染力便大打折扣。这正是当…

张小明 2026/1/3 19:57:42 网站建设

静态网站什么样代做作业网站

Excalidraw 手绘风格图表如何通过 AI 实现精准与美观的统一 在一场远程产品评审会上,产品经理对着空白的白板迟疑了几秒——她需要快速画出一个微服务架构图,但既担心画得不够清晰,又怕太过规整显得冷漠疏离。这时她轻点“AI 生成”&#xff…

张小明 2026/1/3 19:57:41 网站建设

四平做网站佳业深圳网站维护一般多少钱

5个真实场景告诉你:DriverStore Explorer如何解决Windows驱动管理难题 【免费下载链接】DriverStoreExplorer Driver Store Explorer [RAPR] 项目地址: https://gitcode.com/gh_mirrors/dr/DriverStoreExplorer 当你发现电脑越来越慢、设备频繁冲突、磁盘空间…

张小明 2026/1/3 14:46:18 网站建设

上海网站建设微信开发WordPress能做门户网吗

摘要 https://arxiv.org/pdf/2509.23316 目标检测在封闭集环境下取得了显著进展,但在实际部署中仍面临两个挑战:对未见类别的泛化能力差,以及在恶劣条件下的鲁棒性不足。先前的研究分别探索了这些问题:可见光-红外检测提高了鲁棒…

张小明 2026/1/3 19:57:37 网站建设

营销型机械网站淘宝 网站建设

LangFlow能否实现视频字幕自动生成与翻译? 在AIGC浪潮席卷内容生产的今天,一个现实问题摆在开发者面前:如何快速为一段外语视频配上精准、流畅的中文字幕?传统做法需要音视频处理、语音识别、自然语言理解、机器翻译和格式封装等多…

张小明 2026/1/3 21:56:47 网站建设

电子商务网站名称和网址wordpress 前端用户中心

第一章:揭秘Open-AutoGLM长链路处理优势(对比3大主流平台性能数据) 在复杂任务自动化场景中,长链路推理能力成为衡量大模型智能水平的关键指标。Open-AutoGLM 通过动态规划与语义路由机制,在多跳问答、跨工具调用等任务…

张小明 2026/1/3 21:56:44 网站建设