是否有可能扩大Facebook的令牌与extendAccessTokenIfNeeded在一个Android应用程序? [英] Is it possible to extend Facebook tokens with extendAccessTokenIfNeeded in an Android app?

查看:171
本文介绍了是否有可能扩大Facebook的令牌与extendAccessTokenIfNeeded在一个Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,这可能影响了很多的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".

最明显的答案是,我做错了什么,但是,一个<一个href="http://developers.facebook.com/bugs/329021273822477/?browse=search_4f72ff9a4923b1722706530">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。然而,这有<一个href="http://stackoverflow.com/questions/9549689/protecting-app-secret-for-extendaccesstoken-usage-java-android">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要求<一个href="http://developer.android.com/reference/android/net/http/AndroidHttpClient.html">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的

The Facebook.apk included in the SDK is quite old. Perhaps this is why the tokens don't refresh on emulators running API 8 and later?

最后,这一切只与那些人有 官方的Facebook应用程序安装!另一种方法需要完成那些人没有官方的Facebook应用程序(只是抱怨吧!)

And lastly, all of this only relates to those people that have the official Facebook app installed! Another method needs to be completed for those people without the official Facebook app (just complaining now!)

有关Facebook的链接

的Facebook,Android的SDK在GitHub上

Facebook的Andr​​oid的教程

Facebook的offline_access权限去precation

<一个href="http://developers.facebook.com/bugs/329021273822477/?browse=search_4f72ff9a4923b1722706530">Facebook bug报告

相关堆栈溢出的问题

<一个href="http://stackoverflow.com/questions/9329564/facebook-60-day-access-token-and-de$p$pcated-offline-access">Facebook 60天访问令牌和德precated Offline_Access

Facebook的访问令牌不能扩展

<一个href="http://stackoverflow.com/questions/9930311/how-would-offline-access-work-after-de$p$pcation-after-may-1st">How 5月1日之后将offline_access后去precation工作?

Facebook的访问令牌不能扩展

<一个href="http://stackoverflow.com/questions/9549689/protecting-app-secret-for-extendaccesstoken-usage-java-android">Protecting应用程序秘密extendAccessToken使用(Java / Android的)

推荐答案

我不知道Android开发,但如果您在使用该功能的问题,也许有卷曲在Android的类似的功能,将让你呼叫 https://graph.facebook.com/oauth/access_token?
    CLIENT_ID = APP_ID和放大器;     client_secret = APP_SECRET和放大器;     grant_type = fb_exchange_token和放大器;     fb_exchange_token = EXISTING_ACCESS_TOKEN

I don't know Android development, but if you're having issues with that function, maybe there's a similar function of CURL within Android that will allow you to call https://graph.facebook.com/oauth/access_token?
client_id=APP_ID& client_secret=APP_SECRET& grant_type=fb_exchange_token& fb_exchange_token=EXISTING_ACCESS_TOKEN

(谷歌透露:的http://thesoftwarerogue.blogspot.com/2010/05/porting-of-libcurl-to-android-os-using.html如何从Android的CURL)

(google revealed: http://thesoftwarerogue.blogspot.com/2010/05/porting-of-libcurl-to-android-os-using.html on how to CURL from Android)

这篇关于是否有可能扩大Facebook的令牌与extendAccessTokenIfNeeded在一个Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆