ACAccountCredential 为 oauthToken 返回 null

2024-03-07

我通过以下方式访问用户的 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)

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

Thanks


我已经通过更新凭据解决了该问题。也就是说,在授予 FB 访问权限之后,但在 ACAccountCredential 的情况下oauthToken返回 nil,我们只需调用 ACAccountStore 的更新帐户凭据。凭证更新后,令牌就有效了!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ACAccountCredential 为 oauthToken 返回 null 的相关文章

随机推荐