I want to do the right thing and gracefully handle things like session expiration, access tokens becoming invalid etc. The API documentation states:
You should plan that a user’s access token may become invalid at any time and you will need to re-authorize for that user in the case that it does. Ensuring you handle this situation gracefully is imperative for a quality user experience.
But I can’t find documentation of what the actual error responses will be from the API in these cases so I’m not sure how to detect them all. Also, how can I cause a session to expire or an access token to become invalid so that I can test my app against these cases?
I see that TwitterKit provides the
refreshSessionClass, can you provide an example usage of these? I presume I use
isExpiredSession to check any error returned from
sendTwitterRequest, and if true, then attempt
refreshSessionClass. If that also fails then kick the user back out to the login screen?
I’m wanting to cover all bases but I can’t seem to find the comprehensive info I need in the docs to design and test against all the authentication/session related fail cases.