objective-c - 将现有 OAuth 凭据迁移到 ACAccountStore 时出错

标签 objective-c ios oauth ios5 twitter-oauth

我在将现有 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

最佳答案

此错误消息是由于使用不正确的 token / secret 组合引起的。我错误地从 OAuth token 中删除了 user_id 前缀。

关于objective-c - 将现有 OAuth 凭据迁移到 ACAccountStore 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7800675/

相关文章:

ios - 将 AdMob 横幅放置在安全区域的顶部 (iPhone X)

authentication - 绕过经过身份验证的 XmlHttpRequest 的同源策略

iphone - 具有可变内容的可滚动 iPhone "detail view"的最佳布局是什么?

objective-c - 如何使用核心数据选择有条件的子对象?

iPhone应用程序内部 "Settings"

objective-c - ios从应用程序内部更改应用程序的通知

java - 使用 Twitter 从 Java Web 应用程序进行注册和身份验证

oauth - 如何验证 Google 身份服务的响应

objective-c - 如何使用 Objective-C 禁用预览图标

objective-c - 无法获取 Collection View 的选定项目