简体   繁体   English

flutter - 如何让用户登录 Google

[英]flutter - How to keep user signed-in with Google

I have used Google Sign In to authenticate users with Firebase Auth, and I successfully get back my Firebase User.我已使用 Google Sign In 通过 Firebase Auth 对用户进行身份验证,并成功找回了我的 Firebase 用户。 I want to keep the user authenticated, when they come back to the app.当他们回到应用程序时,我想保持用户的身份验证。 How can I do the same?我怎样才能做同样的事情?

Users already stay authenticated.用户已经保持身份验证。 After you restart the app, Firebase reads the credentials from disk, and refreshes the user's token.重新启动应用程序后,Firebase 从磁盘读取凭据,并刷新用户的令牌。 Since this requires a roundtrip to the server, it happens asynchronously.由于这需要到服务器的往返,所以它是异步发生的。 So be sure to await _auth.currentUser() to get notified of the user's status.所以一定要await _auth.currentUser()以获取用户状态的通知。

Whenever I'm wondering how to do such things, I look at the FlutterFire sample app .每当我想知道如何做这些事情时,我都会查看FlutterFire 示例应用程序 This specific line can be found here .可以在此处找到此特定行。

是的,您需要执行auth.currentUser()函数以保持用户身份验证,最好的部分是即使用户离线,该函数也能工作,这使得它非常通用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何保持用户登录 Flutter Firebase 应用程序? - How to keep user signed in Flutter Firebase app? Flutter 如何让用户保持登录状态? - How to keep user logged in in Flutter? Flutter:如何使用 Google Map 保持小部件不变? - Flutter: how to keep widget with Google Map unchanged? 如何检查 Firebase 用户最近是否登录了 Flutter 应用程序 - How to check if the Firebase user has recently signed in in a Flutter app 如何验证用户是否已经登录 flutter - How to verify whether user has already signed In or not in flutter Flutter - 即使在退出并使用另一个帐户登录后,Google 登录也会使用以前登录的帐户(用户) - Flutter - Google Sign In uses previously signed in account (user) even after signing out and signing in with another account Firebase、Flutter:检查用户是否使用 Apple 登录 - Firebase, Flutter: Check if User Signed In With Apple 如何使 Google map 可拖动并将标记保持在 Flutter 的屏幕中央? - How to make Google map draggable and keep marker in the center of the screen on Flutter? 如何使用 Firebase 身份验证保持用户登录 Flutter web 应用程序 - How to keep a user logged in Flutter web app using Firebase Authentication 在 Flutter 中使用电话身份验证时如何保持用户登录 - How to keep user logged in while using Phone Authentication in Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM