When I have a user that is logged in via TwitterKit 3.0.3, and I try to use that user’s session to call a REST api via the TWTRAPIClient, what is the best course of action to take if the api returns a HTTP 401 code 89? I know this means that the user token in the session is no longer valid, but I’m curious if I can do anything via the SDK to refresh/renew the token, or if I have to just log that user out, and have them log back in?
Error Domain=TwitterAPIErrorDomain Code=89 “Request failed: unauthorized (401)” UserInfo={NSLocalizedFailureReason=Twitter API error : Invalid or expired token. (code 89), NSLocalizedDescription=Request failed: unauthorized (401), NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/user_timeline.json?count=25&screen_name=ConveneTeam, TWTRNetworkingStatusCode=401}
Calling isExpiredSession: for this case returns false for some reason, and calling refreshSessionClass:sessionID:completion: doesn’t do the trick either. Do I just log the user out and start over?
TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore];
NSString *userID = store.session.userID;
[store logOutUserID:userID];