Android Facebook 应用程序:访问令牌过期 (expires_in) 始终为 0
我正在开发一个使用 Facebook 集成的应用程序。我正在尝试从 facebook 库类接收 access_token 和 expires_in 令牌。一旦我登录,我就正确地获得了access_token,但我总是得到expires_in令牌始终为0。因此,我的isSessionValid()方法总是返回false。如果有人遇到过这个问题并解决了,请告诉我。
当我没有在模拟器中安装 Facebook 应用程序时,我的代码运行得非常好。我获得了网络视图,并且可以登录并更新状态。但是,当我安装 Facebook 应用程序时,单击更新状态菜单选项将打开 Facebook 应用程序,我被重定向到权限页面,然后收到一条错误消息“无法接收访问令牌”。这实际上是因为 expires_in 令牌为 0。
我不想要求应用程序的用户卸载 Facebook 应用程序(如果他们已安装)。请让我解决这个问题。
谢谢,
普尼特
I am developing an app which uses facebook integration. I am trying to receive the access_token and expires_in tokens from the facebook library classes. Once i am logged in I get the access_token correctly but i always get expires_in token always 0. And because of that I isSessionValid() method always returns false. Kindly let me know if anyone has faced this issue and solved it.
My code runs perfectly fine when i do not have the Facebook app installed in the emulator. I get the webview and I can log in and update status. But when I install Facebook app, clicking on the update status menu option opens the Facebook app, I get redirected to the permissions page and then I get an error saying " Failed to receive access token". This is infact because of the expires_in token being 0.
i do not want to ask the users of the app to uninstall the Facebook app if they have installed. kindly let me the solution to this problem.
Thanks,
Punit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您设置了
offline_access
权限,则令牌过期时间为 0。对于任何其他遇到此问题的人(如果您设置了
offline_access
权限并随后删除),请按照以下步骤操作:或者,您可以执行以下操作:
offline_access
权限)。If you put permission
offline_access
, the token expiry is 0.For any one else having this issue (if you had put
offline_access
permission and later removed) follow the steps:Alternately you can do this:
offline_access
permission now).您在 Facebook 上创建的应用程序中是否提到过 Key Hash?如果没有,请创建一个有效的并提及它。这通常是因为 facebook 的新更新功能而发生,但是,旧版本的 facebook 每次都运行良好。您可以通过卸载 Facebook 应用程序上的更新来检查这一点,然后运行您的代码。它仍然工作正常。从此处了解更多信息
Have you mentioned Key Hash in the app that you created on facebook? If not, create a valid one and mention it. This usually occurs because of the new update features of facebook, However, older versions of facebook work well each time. You can check this by uninstalling updates on your facebook app, and run your code. It still works fine. Learn more from here