AWS ExpiredTokenException after app relaunch

后端 未结 2 1293
暗喜
暗喜 2021-01-21 15:39

I\'m building an iOS (Swift) app using AWS as the backend with Developer Authenticated Identities. Everything works fine until I close the app, leave it for a while and then rel

相关标签:
2条回答
  • 2021-01-21 16:29

    Unfortunately developers refreshing the token is the only way.

    I agree that it would be simpler for app developers if AWS SDK handled this but the way CrdentialsProvider is designed is supposed to be generic for all providers. For example, if someone wants to use Facebook as provider then AWS SDK will not be able to handle the refresh on its own and developer will have t handle that in his app. Keeping the refresh flow out of the SDK gives us the capability to keep the CredentialsProvider generic.

    0 讨论(0)
  • 2021-01-21 16:46

    The AWS Mobile SDK for iOS 2.4.x has a new protocol called AWSIdentityProviderManager. It has the following method:

    /**
     * Each entry in logins represents a single login with an identity provider.
     * The key is the domain of the login provider (e.g. 'graph.facebook.com') and the value is the
     * OAuth/OpenId Connect token that results from an authentication with that login provider.
     */
    - (AWSTask<NSDictionary<NSString *, NSString *> *> *)logins;
    

    The responsibility of an object conforming to this protocol is to return a valid logins dictionary whenever it is requested. Because this method is asynchronous, you can make networking calls in it if the cached token is expired. The implementation is up to you, but in many cases, AWSIdentityProviderManager manages multiple AWSIdentityProviders, aggregates them and return the logins dictionary.

    0 讨论(0)
提交回复
热议问题