meowmeowmeow meowmeowmeow - 4 months ago 109
Swift Question

Request failed: forbidden (403) for fabric twitterkit

I'm trying to extract the members of a list using the TwitterKit API for iOS. As I understand, doing this will allow me to be "guest-authenticated" bypassing the need for my personal consumer and consumer-secret keys.

The code below attempts to get the members of a list using this REST endpoint

let client = TWTRAPIClient()
let endpoint = ""
let params = ["owner_screen_name" : "palafo", "slug" : "breakingnews"]
var clientError : NSError?

let request = client.URLRequestWithMethod("GET", URL: endpoint, parameters: params, error: &clientError)

client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if connectionError != nil {
print("Error: \(connectionError)")

do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: [])
print("json: \(json)")
} catch let jsonError as NSError {
print("json error: \(jsonError.localizedDescription)")

Running that gives me this error:

Error Domain=TwitterAPIErrorDomain Code=220 "Request failed: forbidden (403)" UserInfo={NSLocalizedFailureReason=Twitter API error : Your credentials do not allow access to this resource (code 220), TWTRNetworkingStatusCode=403, NSErrorFailingURLKey=, NSLocalizedDescription=Request failed: forbidden (403)})

If I change
to instead get the statuses in that list using this other REST endpoint, I get a proper JSON response.

let endpoint = ""

Does this mean that Fabric's guest authentication does not allow me to get the members of a list?


I solved mine by using clientWithUserId instead of just initializing using just init.

NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];