在Android应用中验证用户的最佳方法是什么?

时间:2020-12-27 20:07:15

I'm a bit confused about the differents way to authenticate user on Android devices. What is the best way to authenticate user in a Android app, in order to call a custom server REST API?

我对在Android设备上验证用户身份的不同方式感到有点困惑。在Android应用中验证用户的最佳方法是什么,以便调用自定义服务器REST API?

Use GoogleAuthUtil like described in these documents:

使用GoogleAuthUtil,如以下文档中所述:

Pro:

  • Quick login, user has not to type password nor to click on a button
  • 快速登录,用户无需输入密码,也无需点击按钮

Con:

  • Not corss-platform

Use Google Sign-In like described on this document:

使用本文档中描述的Google登录:

Pro:

  • Cross-platform

Con:

  • User has to click on the Google Sign-In button
  • 用户必须单击Google登录按钮

It's possible to easily combine the two way, GoogleAuthUtil when users use Android device and Google sign*in when users are on other platform ?

当用户使用Android设备时,可以轻松地将GoogleAuthUtil和用户在其他平台上的Google sign *组合在一起吗?

1 个解决方案

#1


0  

What do you mean with cross platform, if you use GoogleAuthUtil and Google SignIn button they are both for Android. You can use them both to achive this, just authenticate first time with Google SignIn button, and then save account (so it doesn't ask you which account you want to use for authentication) and access token to SharedPreferences and reuse it for next login (without clicking on SignIn button again)

您对跨平台的意思是什么,如果您使用GoogleAuthUtil和Google SignIn按钮,它们都适用于Android。您可以使用它们来实现此目的,只需使用Google SignIn按钮进行首次身份验证,然后保存帐户(因此它不会询问您要使用哪个帐户进行身份验证)并将令牌访问到SharedPreferences并重新使用它以便下次登录(没有再点击SignIn按钮)

#1


0  

What do you mean with cross platform, if you use GoogleAuthUtil and Google SignIn button they are both for Android. You can use them both to achive this, just authenticate first time with Google SignIn button, and then save account (so it doesn't ask you which account you want to use for authentication) and access token to SharedPreferences and reuse it for next login (without clicking on SignIn button again)

您对跨平台的意思是什么,如果您使用GoogleAuthUtil和Google SignIn按钮,它们都适用于Android。您可以使用它们来实现此目的,只需使用Google SignIn按钮进行首次身份验证,然后保存帐户(因此它不会询问您要使用哪个帐户进行身份验证)并将令牌访问到SharedPreferences并重新使用它以便下次登录(没有再点击SignIn按钮)