【问题标题】:retrieving facebook token expiry from ACAccountStore/ACAccount?从 ACAccountStore/ACAccount 检索 Facebook 令牌到期?
【发布时间】:2013-06-18 17:32:52
【问题描述】:

在使用ACAccountStoreACAccount 时,有什么方法可以判断您的Facebook 令牌何时到期?

我创建了一个ACAccountStore,访问用户的Facebook 帐户,将该帐户存储在ACAccount 对象中,并且能够从凭据中检索令牌。不过,我也想知道这个令牌什么时候到期。我将如何着手取消此令牌的到期?还是有可能?

【问题讨论】:

    标签: ios facebook ios6


    【解决方案1】:

    您为什么想知道它什么时候到期?

    当您获得令牌时,在 Facebook 的情况下,它的令牌生命周期会延长。我认为今天是额外的 60 天。因此,当您从帐户商店获得它时,应该很好。

    如果用户正在使用您的应用,然后决定从 Facebook 设置本身撤消权限,您应该关注的唯一细节。

    在这种情况下,您需要确保您正在监视ACAccountStoreDidChangeNotification 通知并适当地调用renewCredentialsForAccount:completion: 以再次请求权限,请参阅Documentation

    例如:

    - (void)accountChanged:(NSNotification *)note
    {
        [self.accountStore renewCredentialsForAccount:(ACAccount *)self.facebookAccount completion:^(ACAccountCredentialRenewResult renewResult, NSError *error){
            if(!error)
            {
                switch (renewResult) {
                    case ACAccountCredentialRenewResultRenewed:
                        // Good
                        break;
                    case ACAccountCredentialRenewResultRejected:
                        // Maybe go back to non logged in status
                        break;
                    case ACAccountCredentialRenewResultFailed:
                        // Maybe internet failed, Facebook is down?
                        break;
                    default:
                        break;
                }
    
            }
            else{
                // Handle error gracefully
            }
        }];
    }
    

    也许this tutorial 可能对你有所帮助。

    【讨论】:

    • 我实际上并不需要我正在使用它的任何信息。我正在使用的 API 需要它以及会话令牌。真的很感谢这个教程,会很有帮助的。
    • 仅供参考,对于那些找不到上述链接教程(“未找到”)的人,看起来 URL 已移至此处:captechconsulting.com/blogs/…
    猜你喜欢
    • 2016-02-17
    • 2012-05-23
    • 2016-04-27
    • 1970-01-01
    • 2019-11-16
    • 2013-02-03
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多