我如何使用 AndroidAccountManager 注销
我可以使用以下代码登录 Android AccountManager
: http://code.google.com/p/google-api -java-client/wiki/AndroidAccountManager
但我不知道如何注销?
i can login with Android AccountManager
with this code:
http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager
But i don't know how to log out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你不知道。当您使用内置的 Android 身份验证时,您可以使用用户在“帐户和同步”控制面板中提供的用户名和密码进行身份验证。一旦获得该身份验证,您就可以使用它来获取一个身份验证令牌,您应该缓存并使用该令牌,直到它变坏为止。
那么,让我们来看看使用“com.google”样式帐户访问谷歌服务的方式。当您的应用程序想要同步时,您最终将使用 AccountManager 进行身份验证(您绝对应该使用 SyncAdapter 来执行此操作)。一旦您进行身份验证,您将获得一个身份验证令牌。这是一串随机字母,充当后续网络调用的“密钥”。您将保存此信息,只要它是好的,您就不需要再次进行身份验证。所以,想要获取......比方说,谷歌金融投资组合。您将 auth-token 包含在 http get 标头中。发生以下两种情况之一:
发生后一种情况有两个原因:
无论如何,您永远不会退出。您只需使用已获取并缓存的身份验证令牌来使用该服务,直到您不再这样做为止。将您获得的身份验证令牌视为会话密钥,只要您使用它,它就保持有效。
You don't. When you use the built-in android authentication, you authenticate using the username and password that the user has provided in the "Accounts and Sync" control panel. Once you have that authentication, you use it to obtain an auth-token which you should cache and use until it goes bad.
So, let's go with the way you access google services using a "com.google" style account. You will end up authenticating using AccountManager, when your app wants to sync (You should definitely be using a SyncAdapter to do this). Once you authenticate, you will get an auth-token. this is a big string of random letters, which acts as a "key" on subsequent web calls. You will save this, and as long as it's good, you won't need to authenticate again. So, want go to fetch... let's say, a google finance portfolio. You include the auth-token as part of the http get header. One of two things happens:
The latter case will happen for two reasons:
In any case, you never log out. You just use the service with the auth token you've obtained and cached, until you don't anymore. Think of the auth token you get as being like a session key that stays good for as long as you're using it.
为什么不通过调用
AccountManager.invalidateAuthToken 文档
Why not just invalidate your current auth token by calling
AccountManager.invalidateAuthToken Documentation
AccountManager 清除密码(帐户帐户)
从 AccountManager:
AccountManager clearPassword (Account account)
From the AccountManager: