简体   繁体   English

我可以使用AccountManager让用户使用他们的Google帐户登录吗?

[英]Can I use AccountManager to let users sign in with their Google account?

I'm creating an app that will need users to create an account. 我正在创建一个需要用户创建帐户的应用。 (Like Facebook or Twitter would require you to.) (像Facebook或Twitter一样需要你。)

BUT, since it's an Android app, should/can I let them sign in with their Google Account using AccountManager or some other service? 但是,因为它是一个Android应用程序,我应该/可以让他们使用AccountManager或其他服务使用他们的Google帐户登录吗? 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. 如果他们只能登录自己的Google帐户并将其设置和其他选项保存到该帐户,那将非常有用。

Main questions summed up: 总结的主要问题:

  1. Is it possible to let a user just use their Google account in my app? 是否可以让用户在我的应用中使用他们的Google帐户?
    • If so, do I use AccountManager to have them sign in and save account information/settings? 如果是这样,我是否使用AccountManager让他们登录并保存帐户信息/设置?
      • 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!) 是的,您可以让用户使用他们的Google凭据登录他们的Google服务,例如,我在Google Tasks上有一个应用程序,我使用Android AccountManager让用户在Android设备上使用他们的Google帐户验证自己(不需要用户输入密码!)

There are some really good examples to get you started: 有一些非常好的例子可以帮助您入门:

用户必须确认您是否可以使用他/她的凭据登录Google服务

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. 为此,您必须使用第三方身份验证API(如OAuth的路标 )才能登录。

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) 在我的tasks / todo应用程序中,我为用户提供了登录选项,使用他们的Android凭据或使用第三方身份验证为想要使用其他帐户登录的用户(该设备上未启用的帐户)

Let me know if you have more questions 如果您有更多问题,请与我们联系

Although it is a new development, Google Plus Sign-in introduced as part of Google Play Services can also be used. 虽然这是一项新开发,但也可以使用作为Google Play服务一部分引入的Google Plus登录。 More info can be found at Android developers blog . 更多信息可以在Android开发者博客上找到。 See example implementation from Banjo app 请参阅Banjo应用程序的示例实现

在此输入图像描述

There seems to be a big limitation - The user need to have Google+ app installed on the device to use this. 似乎存在很大的限制 - 用户需要在设备上安装Google+应用才能使用此功能。

在此输入图像描述

Also this is a pretty good blog if someone is interested in implementing the solution. 如果有人对实施解决方案感兴趣,这也是一个非常好的博客

@Soham gave you some very useful links but he didn't correct one major error: @Soham给了你一些非常有用的链接,但他没有纠正一个重大错误:
AccountManager is the entity that manages the accounts on your Android device - it has nothing to do with your google account! AccountManager是管理Android设备帐户的实体 - 它与您的Google帐户无关! you can use google account and create a NEW account on your device using the AccountManager. 您可以使用Google帐户并使用AccountManager在您的设备上创建一个新帐户。

The rest you can learn from the links Soham gave you. 其余的你可以从Soham给你的链接中学习。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM