I am trying to populate and save an ACAccount to ACAccountstore, as follows:
ACAccount *account = [[ACAccount alloc]initWithAccountType:twitterAccountType];
account.username = @"hansaaaha";
while (twitterRequest.rstring == nil)
{
continue;
}
NSString *credentails = twitterRequest.rstring;
NSString *oAuthToken = [credentails componentsSeparatedByString:@"&"][0];
NSString *oAuthSecret = [credentails componentsSeparatedByString:@"&"][1];
oAuthToken = [oAuthToken componentsSeparatedByString:@"="][1];
oAuthSecret = [oAuthSecret componentsSeparatedByString:@"="][1];
account.credential = [[ACAccountCredential alloc]initWithOAuthToken:oAuthToken tokenSecret:oAuthSecret];
[store saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
if (success)
NSLog(@"a");
else
NSLog(@"Error: %@", error);
}];
Once twitterRequest.rstring (separate thread) is not nil, I get the token and secret.
I probably shouldn't post them in full here, but this is what
credentials
looks like once it is populated:
oauth_token=OAtSGoYoXXXXXXXXXXXXXXhtUs4AT&oauth_token_secret=cGFYzLTqxXXXXXXXXXXXbC6JEHtK&oauth_callback_confirmed=true
So after sub stringing, I have
oAuthToken: OAtSGoYoXXXXXXXXXXXXXXhtUs4AT
oAuthSecret: cGFYzLTqxXXXXXXXXXXXbC6JEHtK
However, saving fails with following error:
Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)"