Reputation: 322
I'm having problems migrating existing OAuth credentials to ACAccountStore in iOS 5.
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);
}];
The end result being:
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
Upvotes: 0
Views: 1441
Reputation: 322
This error message is caused by using an incorrect token/secret combination. I was incorrectly trimming the user_id prefix off of the OAuth token.
Upvotes: 1