是否有可能扩大Facebook的令牌与extendAccessTokenIfNeeded在一个Android应用程序?有可能、令牌、应用程序、Facebook

2023-09-05 06:30:39 作者:十年很久你们别走

我想,这可能影响了很多的Facebook / Android开发者,但似乎没有来是因为在主题更多的讨论......

I think this might effect a lot of Facebook/Android developers and yet there does not seem to be that much discussion on the topic...

我的提问

有没有人成功刷新用extendAccessTokenIfNeeded功能的令牌?如果你确实有成功的,是什么版本的设备(或仿真器)运行?的

Has anyone successfully refreshed a token using the extendAccessTokenIfNeeded function? If you did have success, what version was the device (or emulator) running?

背景

我从Facebook收到一封电子邮件,该offline_access许可,将从2012年5月1日和Facebook pcated德$ P $建议升级到最新的SDK。精细。

I received an email from Facebook saying the offline_access permission will be deprecated from May 1st 2012 and Facebook recommended upgrading to their latest SDK. Fine.

我升级到最新的SDK,官方的Facebook应用程序安装在我的设备和(最终!)单点登录上似乎是工作确定。我收到60天令牌而这又是确定。

I upgraded to the latest SDK, the official Facebook app is installed on my device and (eventually!) Single Sign On seems to be working OK. I am receiving 60 day tokens which again is OK.

问题开始时,我试图用extendAccessTokenIfNeeded(上下文的背景下,的ServiceListener的ServiceListener)。我无法得到它刷新我的标记更长的到期时间。我等24小时尝试之间,但令牌不会刷新。我可以得到一个刷新令牌的唯一方法是注销并登录。当我用这个例子项目Hackbook这也发生了。

Problems started when I tried to use extendAccessTokenIfNeeded(Context context, ServiceListener serviceListener). I could not get it to refresh my tokens for a longer expiry time. I waited 24 hours between attempts but the token would not refresh. The only way I can get a refreshed token is to log out and login. This also happened when I used the example project "Hackbook".

最明显的答案是,我做错了什么,但是,一个bug报告提交给Facebook的说......shouldExtendAccessToken将实际上几乎总是返回假的。这份报告已被赋予优先心愿。

The most obvious answer is that I am doing something wrong, but, a bug report was submitted to Facebook saying that... "shouldExtendAccessToken will practically almost always return false." This report has been given the priority "wishlist".

的替代方案extendAccessTokenAsNeeded()

在 Facebook的文档中关于offline_access德precation 令牌可以使用图形扩展API。然而,这有disadvantage对需要的应用程序秘密被包含在URL中。一个优点是,用户将不需要有官方Facebook应用程序安装在他们的设备上。

In the Facebook documentation about offline_access deprecation tokens can be extended using the Graph API. However this has the disadvantage of needing the "App Secret" being included in the URL. An advantage is that the user would not need to have the official Facebook app installed on their device.

其他的想法和顾虑

通过改变Facebook.java的extendAccessTokenIfNeeded函数总是返回true,我想我得到了它刷新一次。 (我说想的原因是因为它不会重复的行为,我怀疑我必须再等24小时前的又一成功任何机会)

By changing the extendAccessTokenIfNeeded function in Facebook.java to always return true, I think I got it to refresh once. (The reason I say "think" is because it won't repeat the behaviour and I suspect I have to wait another 24 hours before any chance of another success)

我注意到,Hackbook要求AndroidHttpClient成为 进口。这是仅适用于API 8起。这是否意味着 称Facebook SSO(尤其是令牌清爽)只可能与API 8,后来工作的设备?

I notice that Hackbook requires AndroidHttpClient to be imported. This is only available for API 8 onwards. Does this mean that Facebook SSO (in particular token refreshing) is only likely to work on devices with API 8 and later?

href="https://github.com/facebook/facebook-android-sdk/"> SDK中包含的 Facebook.apk的