Spring Boot Facebook Starter如何登录多个用户?如何获取accessToken或providerId [英] Spring Boot Facebook Starter how to login several users? how to obtain accessToken or providerId

查看:177
本文介绍了Spring Boot Facebook Starter如何登录多个用户?如何获取accessToken或providerId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遵循了几个教程,并且非常接近于理解与Facebook API的弹簧整合,在其他弹簧模块中有很强的知识,我发现自己感到惊讶...

I've followed several tutorials and got really close to nowhere understanding spring integration with facebook API, having strong knowledge in other spring modules I found myself surprised...

每个教程使用:

public <A> Connection<A> findPrimaryConnection(Class<A> apiType) {
    String providerId = getProviderId(apiType);
    if (connections.containsKey(providerId)) {
        return (Connection<A>) connections.get(providerId).get(0);
    }
    return null;
}

这样每次都会返回第一个连接?

As this returns me first connection every time?

我尝试从两个不同的机器连接到我的应用程序,并且两个请求都返回相同的Facebook个人资料..

I've tried connecting to my app from two different machines and both requests return same facebook profile..

像往常一样,我去了调查api什么是获取用户特定的连接,当我想要的方法绊倒:

So as usual I went to investigate api what is required to obtain user-specific-connection when stumbled upon method which does what I want:

public <A> Connection<A> getConnection(Class<A> apiType, String providerUserId) {
        return (Connection<A>) getConnection(new ConnectionKey(getProviderId(apiType), providerUserId));
    } 

好的,所以我试图找出如何获取providerId ...我失败了很多问题,例如:

Ok, so I went trying to figure out how to obtain providerId... I fail, many questions such as:

如何通过providerId,accessToken和secret来获取providerUserId? (Spring Social)

不要更清楚。

似乎我不是第一个失败的理解与Spring融合的哲学。对于我们许多人来说,很明显,我们希望使用高级功能,每个用户都需要自己连接到Facebook,并返回自己的数据,并可以通过Facebook登录。

It seems I am not the first to fail understand philosophy of Spring integration with facebook. As to many of us it is obvious that we want to use advanced features where every user needs to have it's own connection to facebook with its own data returned and possibility to login via facebook.

可以请你解释一下,如何使用每个用户连接/ Facebook对象,因为这个spring模块的实现非常迷失方向。

Could you kindly please explain how to get connection/facebook object per user as I am very disoriented by the implementation of this spring module.

支持并发用户登录到Facebook?对我来说,像建筑美丽的艾菲尔铁塔,没有任何门就感觉到了。

Does Spring Social Facebook even support concurrent users logged in to Facebook? It all feels to me like building beautiful Eiffel tower without any doors.

我没有使用Spring Security集成,因为我觉得ConnectController方法会提供更多的控制,但显然它没有并有偏见的假设。现在看Spring Security的整合。

I didn't use Spring Security integration as I felt ConnectController approach will provide more control, but apparently it does not and has biased assumptions. Now looking at Spring Security integration.

推荐答案

我在一个月前尝试过,发现也很混乱。
对我来说,看起来好像所有这些春天社交的东西都试图用OAuth交互地识别你的网络应用的用户。

I tried thi myself some month ago and found it also very confusing. For me it looked like as if all this spring-social stuff is trying to identify a user of your web-app interactively using OAuth.

我正在寻找的是将我的弹簧应用程序连接到Facebook,例如发贴在那里。
为此,您可以使用FacebookTemplate并忘记提供程序等。

What I was looking for was connecting my spring application to facebook to e.g. post something there. For this purpose you can use the FacebookTemplate and forget about the provider etc. :

public String postOnFacebook(Machine machine, String url) {
    Facebook facebook = new FacebookTemplate(accessToken);
    FacebookLink link = createLink(machine, url);
    // the first parm is the title on top of the message
    String message = facebook.feedOperations().postLink("message", link);
    return message;
}

您需要Facebook帐户的accessToken,这是一个不同的故事。最后,这有助于:
http:// www。 slickremix.com/facebook-60-day-user-access-token-generator/

You need an accessToken for the facebook account, which is a different story. Finally this helped : http://www.slickremix.com/facebook-60-day-user-access-token-generator/

这篇关于Spring Boot Facebook Starter如何登录多个用户?如何获取accessToken或providerId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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