Error code 403 when using guest authentication with TwitterKit iOS for getting user timeline
Asked Answered
C

1

2

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 "https://api.twitter.com/1.1/statuses/user_timeline.json"

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=https://api.twitter.com/1.1/guest/activate.json, 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)
        Fabric.with([Twitter.sharedInstance()])

        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!)!
                self.constructTweetView(self.twitterJson)
            }
            else {
                print("Error: \(connectionError)")
            }

I am on the most recent version of TwitterKit(>2.0)

How can I go about resolving this ?

Thanks!

Corrientes answered 1/4, 2016 at 5:13 Comment(1)
Do you solve this problem , I have the same issue :( .Handsel
S
1

Add key in exception domains as shown in info.plist. Following fixed bug for me.

enter image description here

Satisfaction answered 2/4, 2018 at 7:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.