通过重新启动应用程序保留CognitoCachingCredentialsProvider

时间:2018-10-23 00:53:36

标签: android amazon-web-services amazon-cognito

我正在使用CognitoCachingCredentialsProvider通过用户池与联合身份合作将我的Android应用连接到AWS服务。

我登录后,一切正常,直到应用程序关闭(或者可能直到会话期满)。但是,当我关闭并重新打开应用程序时,尝试访问AWS服务时开始出现Unauthorized access错误。我认为也许在refresh上调用CognitoCachingCredentialsProvider可以解决这个问题,但前提是这是一个过期的会话。但是当我这样做时,我得到NotAuthorizedException: Access to Identity [one of the Identities in the Federated Identities Identity browser] is forbidden.

在进一步调查中,getCachedIdentityId返回了我期望的值,因此this question并没有太大帮助;但是CognitoCachingCredentialsProvider.getLogins在重新启动时始终为空。

空登录是否会阻止刷新?如果是这样,我如何让它们在应用重新启动后得以持久?如果没有,该如何在需要时刷新令牌?

最终,我如何利用CognitoCachingCredentialsProvider来达到最终的目标,即每次重新打开应用程序时都不需要用户重新登录?

0 个答案:

没有答案