简体   繁体   English

使用Facebook4j API登录Facebook?

[英]Facebook Login With Facebook4j API?

I am using Facebook4j for interaction with facebook through my Java web application . 我正在使用Facebook4j通过我的Java Web应用程序与Facebook进行交互。 i want to know What Data I have to save Into database So Next time When user come to my application no need to further 我想知道我必须将哪些数据保存到数据库中,所以下次当用户来到我的应用程序时,无需进一步操作

        String code = request.getParameter(OAUTH_CODE);
        if (code != null && code.length() > 0) {

            LOGGER.debug("We have a oauth code: {}.", code);
            LOGGER.debug("Attempting to verify the code...");

            Verifier verifier = new Verifier(code);

            LOGGER.debug("Trading the Request Token for an Access Token...");

            Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);

            Token accessToken1 = new Token(token, apiSecret);

And now save these accessToken1 into database but everytime when i login from diffrent account i am getting same AccessToken ..What i am doing wrong? 现在将这些accessToken1保存到数据库中,但是每次当我从不同的帐户登录时,我都会得到相同的AccessToken ..我在做什么错呢? or what information i have to save into database 或我必须保存到数据库中的哪些信息

Where is your OAUTH_CODE coming from? 您的OAUTH_CODE来自哪里? If that is the same each time then your token will be the same too. 如果每次都相同,那么您的令牌也将相同。 How about the variable "token"? 变量“ token”如何? Is that your FB APP ID? 那是你的FB APP ID吗? So AccessToken1 is the APP token and accessToken is the user token? 那么AccessToken1是APP令牌,accessToken是用户令牌?

The idea behind OAUTH is, that a user authorizes an app to do things in his/her name for a short amount of time. OAUTH背后的想法是,用户授权应用程序在短时间内以他/她的名义做事。 After is amount of time has passed the user has to authorize that app again. 经过一段时间后,用户必须再次授权该应用。 So there is nothing you can save that will help, your app will always need user interaction ;) 因此,您无法保存的任何东西都将对您有所帮助,您的应用将始终需要用户交互;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM