Pregunta

Tengo problemas para migrar las credenciales de OAuth existentes a Acaccountstore en 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);
}];

El resultado final es:

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
¿Fue útil?

Solución

Este mensaje de error es causado por el uso de una combinación de token/secreto incorrecto. Estaba recortando incorrectamente el prefijo user_id fuera del token OAuth.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top