objective-cmacostwitterosx-mavericksslrequest

Twitter SLRequest on OSX returns error 32


Executing an SLRequest for Twitter on OSX Mavericks 10.9 returns "Could not authenticate you" with error code 32 for any Twitter API request. The simple code snippet is below.

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {

    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
    ACAccount *account = [accountsArray lastObject];

    NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/help/test.json"];
    SLRequest *r = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:url parameters:nil];
    r.account = account;

    [r performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
        dispatch_semaphore_signal(semaphore);
    }];

}];

dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

What is strange to me is that this exact same code snippet works on iOS without any problems. ACAccount seems valid, preparedURLRequest seem to have all OAuth HTTP headers, I'm not sure what could possibly be wrong... Any ideas?


Solution

  • Apparently, this URL doesn't exist on HTTP nor HTTPS anymore except at the time of the question post, Twitter was responding with error 32 which, I guess, is a bug.

    Anyway, everything works alright with other URLs.