ACAccountCredential为oauthToken返回null

我通过以下方式访问用户的Facebook:

[accStore requestAccessToAccountsWithType:fbAccountType options:options completion:^(BOOL granted, NSError *error) { if (granted) { // If access granted, then get the Facebook account info NSArray *accounts = [accStore accountsWithAccountType:fbAccountType]; ACAccount *acc = [accounts lastObject]; // Get the access token, could be used in other scenarios ACAccountCredential *fbCredential = [acc credential]; NSString *accessToken = [fbCredential oauthToken]; NSLog(@"Facebook Access Token: %@", accessToken); // Add code here to make an API request using the SLRequest class } else { NSLog(@"Access not granted"); } }]; 

打印出:

  Facebook Access Token: (null) 

我被授予访问权限,但令牌为空。 我究竟做错了什么?

谢谢

我通过续订凭证解决了这个问题。 也就是说,在授予对FB的访问权限后,但在ACAccountCredential的oauthToken返回nil的情况下,我们只需调用ACAccountStore的renewCredentialsForAccount 。 续订凭证,之后令牌有效!

以下是Apple doc的一些信息:

@property(非primefaces,保留)ACAccountCredential *凭证讨论此属性是必需的,必须在保存帐户之前设置。 出于隐私原因,保存帐户后无法访问此媒体资源。

与您的代码一样,[acc credential]将返回null

供参考, http://developer.apple.com/library/ios/#documentation/Accounts/Reference/ACAccountClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40011019

在这里找到类似的post: 从Social.framework(iOS6)获取Facebook访问令牌

希望这可以提供帮助。