title: Error creating twitter ACAccount on iOS5: NSURLErrorDomain error -1012
body: <p>I am having trouble creating and saving a new twitter account to <code>ACAccountStore</code> on iOS5. </p>
  
  <p>After performing all the steps to init the account, <code>ACAccountStore's</code> <code>saveAccount:withCompletionHandler:</code> returns <code>NSURLErrorDomain error -1012</code>.</p>
  
  <p>Does anyone have similar issues?</p>
  
  <p>My code sample below is using requestToken to init <code>ACAccountCrendential</code>. This object is an <code>OAToken</code> (ShareKit object) initialized with the token and secret received from twitter after completing <code>OAuth</code>. </p>
  
  <pre><code>    ACAccountStore *store = [[[ACAccountStore alloc] init] autorelease];
      ACAccountType *twitterAccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
      ACAccount *account = [[[ACAccount alloc] initWithAccountType:twitterAccountType] autorelease];
  
      account.username = @"twitterusername";
      account.credential = [[[ACAccountCredential alloc] initWithOAuthToken:requestToken.key tokenSecret:requestToken.secret] autorelease]; 
      [store requestAccessToAccountsWithType:twitterAccountType withCompletionHandler:^(BOOL granted, NSError *error) {
          if (granted) {
              [store saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
                  if (success) {
                      NSLog(@"TWITTER ACCOUNT CREATED SUCCESSFULLY!");
                  }
                  else{
                      NSLog(@"ERROR creating twitter account: %@", [error description]);
                  }
              }];
          }
      }]; 
  </code></pre>
  
  <p>The strange thing is that Apple's <a href="http://developer.apple.com/library/ios/documentation/Accounts/Reference/AccountsFrameworkRef/AccountsFrameworkRef.pdf" rel="nofollow">Accounts Framework Reference</a> suggests that <code>saveAccount:withCompletionHandler:</code> attempts to perform <code>OAuth</code> itself:</p>
  
  <blockquote>
    <p>If the account type supports authentication and the account is not authenticated, the account is authenticated
    using its credentials. If the authentication is successful, the account is saved; otherwise, it is not saved.</p>
  </blockquote>
  
  <p>I find that very strange since there is no way for the user to authenticate directly with the server by inputting username/password. </p>
  
  <p>I also tried to initialize <code>ACAccountCredential</code> with my application's consumer key and consumer secret, with the same result (failed with <code>NSURLErrorDomain error -1012.</code>)</p>
  
  <p>Any guidance on this topic would be greatly appreciated! </p>
  
  <p>thanks.</p>