Android 的客户经理如何使用存储的密码来检索授权令牌?

How does Android's account manager use the stored password to retrieve an auth token?

我的问题是关于 Android 客户经理的。我不确定我是否理解以下文档:

http://developer.android.com/reference/android/accounts/AccountManager.html

对于方法: public AccountManagerFuture getAuthToken (Account account, String authTokenType, Bundle options, Activity activity, AccountManagerCallback 回调, Handler handler)

上面写着:

If a previously generated auth token is cached for this account and type, then it is returned. Otherwise, if a saved password is available, it is sent to the server to generate a new auth token. Otherwise, the user is prompted to enter a password.

我不明白客户经理会如何针对我的帐户类型执行此操作。我的假设是它会调用 AbstractAccountAuthenticator 中定义的方法来执行此操作,但我没有看到任何方法似乎会重新提交已保存的密码。

  1. 澄清一下,我打算为我的帐户保存一个刷新令牌作为 'password'。然后我打算提交刷新令牌来代替存储的密码,以获得新的访问令牌。

  2. 我尝试在 GrepCode 中搜索,但我不习惯那里显示代码的方式,或者代码不是很清楚,因为我仍然不确定客户经理如何计划'resubmit' 存储的密码,如果我可以覆盖该行为,那么它只会刷新访问令牌。

感谢任何帮助。我觉得我在这里遗漏了一些非常明显的东西。

覆盖 getAuthToken。在该覆盖中,您将执行上述工作流程。保存密码是可选的。如果您不想保存密码,那么在 getAuthToken 中您只需验证已保存的令牌。如果令牌无效,您将提示登录或仅使用您要求定义的其他机制刷新令牌。