首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正在从ACAccountStore/ACAccount检索facebook令牌过期日期?

正在从ACAccountStore/ACAccount检索facebook令牌过期日期?
EN

Stack Overflow用户
提问于 2013-06-19 01:32:53
回答 1查看 838关注 0票数 3

在使用ACAccountStoreACAccount时,有没有办法判断你的facebook token什么时候会过期?

我创建了一个ACAccountStore,访问用户的facebook帐户,将该帐户存储在一个ACAccount对象中,并且能够从凭据中检索令牌。我也想知道这个令牌什么时候到期。我该如何拉取这个令牌的过期时间呢?或者这有可能吗?

EN

回答 1

Stack Overflow用户

发布于 2013-06-19 01:47:32

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

在Facebook的例子中,当你获得一个令牌时,它的令牌生命周期被延长了。我想今天这是额外的60天。因此,当您从帐户存储中获得它时,它应该可以运行了。

如果用户正在使用您的应用程序,然后决定撤销Facebook设置本身的权限,那么您应该关注的唯一细节是。

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

例如:

代码语言:javascript
复制
- (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可能会对你有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17175298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档