我在将现有OAuth凭据迁移到iOS 5中的ACAccountStore时遇到问题。
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
ACAccount *account = [[ACAccount alloc] initWithAccountType:accountType];
ACAccountCredential *credential = [[ACAccountCredential alloc] initWithOAuthToken:savedToken tokenSecret:savedSecret];
[account setCredential:credential];
[accountStore saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
if (error) {
NSLog(@"error saving account: %@", error.description);
}
NSLog(@"saved account? %d", success);
}];
最终结果是:
2011-10-17 19:09:32.927 League[13731:1b803] error saving account: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)"
2011-10-17 19:09:32.927 League[13731:1b803] saved account? 0
答案 0 :(得分:1)
此错误消息是由使用不正确的令牌/机密组合引起的。我错误地修改了OAuth令牌的user_id前缀。