无法使用 OAuth 2.0 从 Facebook 获取用户信息
用户登录后,我就使用以下代码检索用户信息:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
它在前几次有效,但最终返回了错误。我认为这是一个会话问题,因为我的权限有“offline_access”。我从 Facebook 注销并从干净的构建中再次编译,但它仍然返回此错误:
错误域=facebookErrDomain代码=10000 UserInfo=0x54a2930“操作无法完成。(facebookErrDomain错误10000。)”
我假设我的访问令牌有效,因为我可以发帖。我的假设正确吗?
我还注意到,每当我登录时,如果我允许我的应用程序访问我的用户信息,Facebook 不会重定向我来请求许可。
谁能告诉我出了什么问题吗?
As soon as the user is logged in, I retrieve the user info using this code:
[_facebook requestWithGraphPath:@"me" andDelegate:self];
It worked for the first few times, but it eventually returned an error. I thought it was a session thing since I have "offline_access" on my permissions. I logged out from Facebook and compiled again from a clean build and it still returns this error:
Error Domain=facebookErrDomain Code=10000 UserInfo=0x54a2930 "Operation could not be completed. (facebookErrDomain error 10000.)"
I'm assuming my access token is valid since I can do posting. Am I right to assume that?
I also noticed that whenever I log in, Facebook doesn't redirect me to ask permission if I allow my app to access my user info.
Can anyone tell me what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
授权命令的答案似乎不同。现在,不像以前那样没有有效期了。我尝试强制 isSessionValid 返回 TRUE,并且它有效。
isSessionValid 检查 accessToken 和过期日期。由于没有到期日期,该函数返回 FALSE。
不知道这是 Facebook 的临时修改还是最终修改。在这种情况下,我认为 SDK 必须修复。新的调用必须检索expirationDate。
Answer on authorize command seems to be different. Now, there's no expiration date as it was before. I tried with forcing isSessionValid to return TRUE, and it works.
isSessionValid checks accessToken AND expirationDate. As there's no expiration date, the function return FALSE.
Don't know if it's a temporary modification from facebook, or definitive one. In this case, SDK must be fixed, I presume. And a new call must retrieve expirationDate.
这是我使用过的临时修复。您可以在 FBLoginDialog.m 中的第 46 行找到此方法。
是否每个遇到此问题的人都请求离线访问权限?这是我看到过期日期未发送的唯一原因。也许尝试不请求offline_access 权限。
Here's a temporary fix I've used. You can find this method line 46 in FBLoginDialog.m
Does everyone with this issue request the offline_access permission? It's the only reason I can see an expiration date not being sent. Maybe try not requestion the offline_access permission.
我也遇到过同样的问题。我检查了我的隐私设置、权限、其他方法等...,但我无法解决它。
很多网站都说“检查访问offline_access/read_stream/publish_stream的权限”,我认为这些也很重要,但我无法修复它。
然后我终于找到了以下解决方案,效果很好。
您应该在“Facebook.m”文件上将“safariAuth:YES”更改为“safariAuth:NO”。
如果您已登录,则可以使用以下方法获取自己的信息。
如果您未登录,则应先通过以下方法登录。
以下帖子救了我。非常感谢!
如何使用 Facebook iOS SDK 检索 Facebook 回复
好运气与快乐编码!
谢谢。
I've had same problem. I checked my privacy settings,permissions,other method etc..., but I couldn't solve it.
Many sites said "check permission for accessing to offline_access/read_stream/publish_stream",I think these are important too,but I couldn't fix it.
Then I found following solution finally, it works fine.
You should change "safariAuth:YES" to "safariAuth:NO" on "Facebook.m" file.
Then you can use following method to get your own info if you are logged in.
if you are not logged in, You should login by following method first.
Following post saved me.Thank you so much!
How to retrieve Facebook response using Facebook iOS SDK
Good Luck & Happy-coding!
Thank you.
我遇到过这个问题,主要是因为我的 Facebook 帐户的隐私权限已达到上限。
这很可能是您在登录期间传入的权限。默认情况下,它只允许访问公共信息。请记住,Facebook 上公开的信息越来越少。
尝试将您的权限更改为“read_stream”,nil
然后而不是 [_facebook requestWithGraphPath:@"me" andDelegate:self];
尝试使用 [_facebook requestWithGraphPath:@"me/home" andDelegate:self];
这应该返回您的新闻提要。
5 分钟前为我工作。
I've had this problem, mainly because my Facebook account has is maxed on privacy.
It's most likely the permissions that you passed in during login. BY default it will only give access to public info. Remember there is less and less info that is public in Facebook.
Try changing your permission to something like "read_stream",nil
Then instead of [_facebook requestWithGraphPath:@"me" andDelegate:self];
Try using [_facebook requestWithGraphPath:@"me/home" andDelegate:self];
This should return your news feed.
Worked for me 5 mins ago.
这里没有太多要添加的,在这里也不起作用。我使用 iOS SDK 发布到流,直到昨天才正常。今天我的客户打电话给我抱怨。啊。
我已经请求了离线访问权限,当然还有“publish_stream”权限......
Not much to add here, doesn't work here too. I use the iOS SDK to post to the stream and it worked until yesterday. Today my client called me and complained. Ugh.
I have requested the offline access permission and of course the "publish_stream" permission...