颤抖-如何保持用户使用Google登录 [英] flutter - How to keep user signed-in with Google

查看:104
本文介绍了颤抖-如何保持用户使用Google登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Google登录来通过Firebase Auth对用户进行身份验证,并且我成功取回了Firebase用户。当他们返回应用程序时,我想保持用户身份验证。我该怎么做?

I have used Google Sign In to authenticate users with Firebase Auth, and I successfully get back my Firebase User. I want to keep the user authenticated, when they come back to the app. How can I do the same?

推荐答案

用户已经保持身份验证。重新启动应用程序后,Firebase从磁盘读取凭据,并刷新用户的令牌。由于这需要往返服务器,因此它是异步发生的。因此,请确保等待_auth.currentUser()来获取用户状态的通知。

Users already stay authenticated. After you restart the app, Firebase reads the credentials from disk, and refreshes the user's token. 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.

无论何时我想知道如何做这些事情,我看了 FlutterFire示例应用程序。可以在此处找到此行

Whenever I'm wondering how to do such things, I look at the FlutterFire sample app. This specific line can be found here.

这篇关于颤抖-如何保持用户使用Google登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆