Every once and awhile, making a guest api call via TWTRAPIClient returns the following error:
Domain=TwitterAPIErrorDomain Code=99 “Request failed: forbidden (403)” UserInfo={NSLocalizedFailureReason=Twitter API error : Unable to verify your credentials (code 99), TWTRNetworkingStatusCode=403, NSErrorFailingURLKey=https://api.twitter.com/oauth2/token, NSLocalizedDescription=Request failed: forbidden (403)}
I’ve been printing out the HTTP headers when this happens, and its looks like there is no active guest session at the time this occurs. For some reason the SDK can’t or isn’t establishing one? Notice there is no x-guest-token or Authorization header.
“User-Agent” = “Fabric/X.Y.Z (Convene_Dev/3.5.0; iOS Simulator (iPhone); iOS 10.2.0 (16G29) iOS; Scale/2.00) TwitterKit/3.1.0”;
When this condition happens, it persists no matter how many api request attempts are made. Killing the app and restarting it fixes the problem. If I look for error code 99, is there any SDK calls I can make to get things going again? Perhaps something like:
let sessionStore = Twitter.sharedInstance().sessionStore
sessionStore.fetchGuestSession { (session, error) in
if let session = session {
//Now we have a guest session, try REST call again?
}
};
Reproduction steps:
-
Call Twitter.sharedInstance().logIn(completion: )
-
Make Guest REST api request:
let client = TWTRAPIClient()
let url = "https://api.twitter.com/1.1/statuses/user_timeline.json"
var clientError : NSError?
let request = client.urlRequest(withMethod: "GET", url: url, parameters: ["screen_name" : "devtester6", "count" : "25"], error: &clientError)
print(request.allHTTPHeaderFields ?? "")
client.sendTwitterRequest(request, completion: { [weak self] (response, data, error) in
}
-
Sometimes you get this error: Domain=TwitterAPIErrorDomain Code=99 “Request failed: forbidden (403)” UserInfo={NSLocalizedFailureReason=Twitter API error : Unable to verify your credentials (code 99), TWTRNetworkingStatusCode=403, NSErrorFailingURLKey=https://api.twitter.com/oauth2/token, NSLocalizedDescription=Request failed: forbidden (403)}
-
Once this error occurs, any number of retries at the api call fail
-
Killing the app and restarting it resolves the issue.