OSX Mavericks 10.9 で Twitter の SLRequest を実行すると、 Twitter API リクエストに対してエラー コード 32 で「Could not authenticate you」が返されます。簡単なコード スニペットを以下に示します。
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);
私にとって奇妙なのは、このまったく同じコード スニペットが iOS でも問題なく動作することです。ACAccount は有効なようで、preparedURLRequest にはすべての OAuth HTTP ヘッダーがあるようです。何が問題なのかわかりません...何かアイデアはありますか?