android - 防止谷歌凭据保存在android中
问题描述
我正在使用Firebase Google Authentication
服务。身份验证工作正常,但问题是当我使用 google auth 登录时,凭据会被保存。因此,每次注销后,我都无法选择登录电子邮件。它直接让我登录到应用程序。因此,当我想使用另一个 Gmail 帐户登录时,这对我来说是个问题。
实现凭证页面的代码。
google_sign_in_btn.setOnClickListener {
signIn()
}
...
private fun signIn() {
val signInIntent = mGoogleSignInClient.signInIntent
startActivityForResult(signInIntent, 234)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 234)
{
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
try
{
val account = task.getResult(ApiException::class.java)
if (account != null) {
firebaseAuthWithGoogle(account)
}
}
catch (e:ApiException) {
}
}
}
解决方案
您面临的问题是您没有从 Google 提供商中注销用户。仅从 Firebase 退出是不够的。如果您希望每次都弹出该弹出窗口,以便选择要使用的电子邮件帐户,请从 Google 和 Firebase 中退出:
googleSignInClient.signOut().addOnCompleteListener { /* ... /* }
FirebaseAuth.getInstance().signOut()
推荐阅读
- angular-material - Mat输入值与显示文本
- python - Python 重新格式化 namedtuple 参数值
- kotlin - 在没有等待的情况下循环调用异步
- python - 从图像生成器绘制图像
- javascript - 如何在具有电子邮件数组的对象数组中找到第一个匹配的对象?
- mysql - 是否可以在 SQL 中使用 AND 运算符和 ON ?
- python - 为什么 PostMessage MOUSEEVENTF_LEFTDOWN 会导致接收应用程序崩溃?
- windows - Windows批处理文件插入空行/删除单行 - nmap输出
- php - 对象不返回带有教义的所有元素
- apdu - 发送 APDU 命令进行超轻 C 身份验证