agorapulse / grails-facebook-sdk

Facebook SDK Grails Plugin
http://agorapulse.github.com/grails-facebook-sdk/guide
30 stars 13 forks source link

How to connect with Grails Spring Security Facebook plugin ? #76

Closed mmaryo closed 7 years ago

mmaryo commented 8 years ago

Hi,

I trie to use this plugin.

I connect the user to facebook with Spring Security Facebook

Then I display a page :

FacebookContext facebookContextProxy
def test() {
    facebookContextProxy.user.exchangeToken()
    long userId = facebookContextProxy.user.id
    println userId
}

The problem is userId is always 0

So I trie to use :

facebookContextProxy.user.exchangeToken()
facebookContextProxy.user.getToken()

userId stay 0

In getId() in FacebookContextUser I see :

context.session.getData('userId')

So maybe I can pass variable throught session

But the problem is

    long getId() {
        if (_id == -1) {
           ...
        }
        return _id
    }

and the _id is always 0

Can you help me

benorama commented 8 years ago

Do you use FB connect on a web site and connect though the FB JS SDK? If you do, check that you have a cookie named fbsr_${YOUR_APP_ID} once you are authenticated. The plugin detect this cookie and parse it to get userId / tokens.

mmaryo commented 8 years ago

Hi

I use spring security facebook authentification plugin I'll trie to add this cookie and give you a response

Cheers

benorama commented 8 years ago

This cookie can only be set by Facebook JS SDK (FB.login method). I suppose that Spring Security Facebook Authentication plugin already does that. My recommandation would be to use only this plugin for authentication and use directly RestFB lib if you want to make Graph API calls?