我可以使用 AccountManager 让用户使用他们的 Google 帐户登录吗? [英] Can I use AccountManager to let users sign in with their Google account?

查看:48
本文介绍了我可以使用 AccountManager 让用户使用他们的 Google 帐户登录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个需要用户创建帐户的应用.(就像 Facebook 或 Twitter 会要求你这样做.)

但是,由于它是一个 Android 应用程序,我应该/可以让他们使用 AccountManager 或其他一些服务使用他们的 Google 帐户登录吗?如果他们只需登录自己的 Google 帐户并将他们的设置和其他选项保存到该帐户中,就会非常有帮助.

主要问题总结:

  1. 是否可以让用户只在我的应用中使用他们的 Google 帐户?
    • 如果是,我是否使用 AccountManager 让他们登录并保存帐户信息/设置?
      • 还有哪些其他选择?

解决方案

是的,您可以让用户使用他们的 Google 凭据登录他们的 Google 服务,例如,我在 Google Tasks 上有一个应用程序并且我使用 Android AccountManager让用户在 Android 设备上使用他们的 Google 帐户进行身份验证(用户无需输入密码!)

有一些非常好的示例可以帮助您入门:

  • 这是对如何根据用户 Android 凭据进行身份验证的深入研究,有一个示例,说明事情如何工作以及 UI 应该如何:

您拥有的其他选项是让用户手动输入他们的用户名/密码.为此,您必须使用第三方身份验证 API(例如用于 OAuth 的 signpost)他们登录.

在我的任务/待办事项应用程序中,我为用户提供了两种登录选项,使用他们的 android 凭据或为想要使用其他帐户(该设备上未启用的帐户)登录的用户使用第三方身份验证

如果您有更多问题,请告诉我

I'm creating an app that will need users to create an account. (Like Facebook or Twitter would require you to.)

BUT, since it's an Android app, should/can I let them sign in with their Google Account using AccountManager or some other service? It'd be very helpful if they could just sign in to their Google account and their settings and other options would be saved to that account.

Main questions summed up:

  1. Is it possible to let a user just use their Google account in my app?
    • If so, do I use AccountManager to have them sign in and save account information/settings?
      • What are other options?

解决方案

Yes, you can get users to log into their Google Services using their Google credentials, for example, I have an app on Google Tasks and I use the Android AccountManager to let users authenticate themselves using their Google account on the android device (No need for users to enter their password!)

There are some really good examples to get you started:

The other options you have is to have users manually enter their username/password. For that you have to use a third party authentication API (like signpost for OAuth) for them to log in.

In my tasks/todo application I provide users both options to sign in, using their android credentials or using third party authentication for users that want to log in using some other account (an account which is not enabled on that device)

Let me know if you have more questions

这篇关于我可以使用 AccountManager 让用户使用他们的 Google 帐户登录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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