Error code 403 when using guest authentication for getting user timeline



I am using Fabric’s twitter kit for getting a username’s tweets in my iOS application by making a request to the REST API endpoint “

I am have correctly set up my “consumer key” and “consumer secret key” as provided by the Fabric app in my AppDelegate and info.plist , but I repeatedly get the following error message -

Error: Optional(Error Domain=TwitterAPIErrorDomain Code=200 “Request failed: forbidden (403)” UserInfo={NSErrorFailingURLKey=, NSLocalizedDescription=Request failed: forbidden (403), NSLocalizedFailureReason=Twitter API error : Forbidden. (code 200)})

My code is as under follows -

            Twitter.sharedInstance().startWithConsumerKey(TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_KEY_SECRET)
            let userId = Twitter.sharedInstance().sessionStore.session()?.userID
            let client = TWTRAPIClient.init(userID: userId)
            let params = ["screen_name": twitterUsername, "count" : "10"]
            var clientError : NSError?
            let request = client.URLRequestWithMethod("GET", URL: TWITTER_TIMELINE_ENDPOINT, parameters: params, error: &clientError)
            client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
                if(connectionError == nil) {
                    self.twitterJson = self.nsdataToJSON(data!)!
                else {
                    print("Error: \(connectionError)")

I am on the most recent version of TwitterKit(>2.0)
How can I go about resolving this ?



Is there any chance that the user you’re trying to retrieve the timeline for is a protected account? In that case, guest authentication would not work.


No, I am sure that the account I am trying to access is not protected.