使用spring-social Facebook的应用程序访问令牌查询公共页面 [英] Use app access token with spring-social facebook to query public pages

查看:165
本文介绍了使用spring-social Facebook的应用程序访问令牌查询公共页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前在此问题中使用了应用访问令牌(如何使用Facebook的AppAccessToken与Spring Social )和 Craig Walls 给出了一个很好的解释,为什么Spring-social API在大多数情况下应该是基于用户的。



我有一个场景,但是我希望我们的服务器端应用程序做出几个不需要用户特定权限的查询。我选择了一个随机的公共页面,例如



我想:





当我测试这些在Graph API资源管理器中( https://developers.facebook.com/tools/explorer )使用App Access令牌他们工作正常。 App访问令牌是通过点击 https://graph.facebook.com/v2.0/oauth/access_token?client_id= {app-id}& client_secret = {app-secret}& grant_type获得的= client_credentials ,并用我的Facebook客户端凭证替换 client_id client_secret



我们的应用程序希望能够为任何给定的名称提供这些信息,以便我们可以对公司的存在进行查询。



我们将对Twitter,LinkedIn和其他人有类似的要求,所以我只想检查是否有任何方法在当前API中执行此操作,或者是否不符合我们的要求。

解决方案

Spring Social的Facebook API绑定尚未支持v2.0,但这是我正在开展的工作,所以希望很快。一旦完成,肯定会有一些操作只能与用户访问令牌一起工作,而某些操作只适用于应用程序访问令牌,有些操作可以使用(FWIW,Twitter的API具有类似的情况)。 p>

关注GitHub中的项目,或者在Twitter上关注@SpringSocial,知道v2.0的内容是否可用。 (我非常感谢任何可以进行测试的帮助。)



尽管通过应用程序令牌请求的连接框架获取您的FacebookTemplate没有任何意义(连接本质上是一个面向用户的概念),您可以随时构建一个FacebookTemplate,无论你需要它,给它一个通过OAuth2Template的authenticateClient()获得的应用程序访问令牌。您当然可以使用v1.0 API绑定来实现 ,但我不确定应用程序令牌可以使用的操作。



FWIW,因为我正在开发v2.0 API绑定,我开始感受到FacebookTemplate携带两个令牌的机会:用户令牌和应用程序令牌。这样,即使从从连接框架获取的FacebookTemplate中,也可以执行以应用为中心的请求。那么你唯一需要手动构建FacebookTemplate的是如果有一些操作可以使用任何一种令牌,但根据使用什么类型的令牌,结果会有所不同。


Using app access token had previously been asked in this question (How to use Facebook appAccessToken with Spring Social) and Craig Walls gave a good explanation why the spring-social API should be user-based for most cases.

I have a scenario, however where I would like our server-side application to make a couple of queries that should not require user-specific permissions. I picked a random public page for examples below

I would like to:

When I test these in the Graph API explorer (https://developers.facebook.com/tools/explorer) using an App Access Token they work fine. App Access Token is obtained by hitting https://graph.facebook.com/v2.0/oauth/access_token?client_id={app-id}&client_secret={app-secret}&grant_type=client_credentials and replacing client_id and client_secret with my Facebook client credentials.

Our application would like to have the ability to make these for any given name so we can make queries about a company's presence.

We will have similar requirements for Twitter, LinkedIn and others so I just wanted to check if there are any means to do this in the current API or whether it will not suit our requirements.

解决方案

Spring Social's Facebook API binding does not (yet) support v2.0, but that's something I'm working on right now...so hopefully soon. Once that's complete, there'll certainly be some operations that work only with user access tokens and some that only work with app access tokens, and some that will work with either (FWIW, Twitter's API has a similar set of circumstances).

Keep an eye on the project in GitHub or follow @SpringSocial on Twitter to know when the v2.0 stuff is available. (I'd appreciate any help I can get in testing it.)

Although it makes no sense at all to obtain your FacebookTemplate via the connection framework for app token requests (connections are, by nature, a user-oriented concept), you can always construct a FacebookTemplate wherever you need it, giving it an app access token obtained via OAuth2Template's authenticateClient(). You can certainly do that now with the v1.0 API binding, but I'm uncertain what ops an app token would work with.

FWIW, as I'm working on the v2.0 API binding, I'm starting to sense an opportunity for FacebookTemplate to carry two tokens: A user token and an app token. This way you can perform app-centric requests even from a FacebookTemplate obtained from the connection framework. Then the only time you'd ever want to construct a FacebookTemplate manually is if there are some operations for which either kind of token will work, but the results would be different depending on what type of token is used.

这篇关于使用spring-social Facebook的应用程序访问令牌查询公共页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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