grails-facebook-graph
grails-facebook-graph copied to clipboard
problem with session.facebook. Is null
Hi, thanks for upgrading so quickly the plugin to oauth 2.0, but i've a problem. After the login with facebook the application correctly redirect to controller QAuth and action facebookLogin
...
<script type="text/javascript">
FB.Event.subscribe('auth.logout', function (response) {
window.location ="${createLink(controller:'QAuth', action:'facebookLogout')}";
});
function facebookLogin() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// logged in and connected user, someone you know
window.location ="${createLink(controller:'QAuth', action:'facebookLogin')}";
}
});
}
</script>
...
but in this action session.facebook is null
after some debugging the problem seems to be in createFacebookData(data) in class FacebookGraphService
at ... if(!facebookData?.access_token || !facebookData?.uid || !facebookData?.expires) { facebookData = null } else { // Setting the expiration date now = Calendar.getInstance() now.add(Calendar.SECOND, facebookData.expires as Integer) facebookData.expiresDate = now.time } ... the facebookData is set to null each time, because the facebookData.expires is null
Notice: the access token and uid are presnt
plugin used : facebook-graph-0.14
I have the same problem (FB login is shown, Facebook redirects to correct page, session.facebook is null) but another effect. In FacebookGraphFilters the cookie from Facebook exists and contains some value (e.g., "e3siXwEgG7xaB...") but the decodeURL() method does not change/decode this value and therefore the validation in facebookGraphService.validateSession(cookie.value.decodeURL()) does not work and returns null!
BTW: I'm not 100% sure where the method decodeURL() is located - maybe the method is not found and therefore not executed? (a new Grails 2.0 method?) FacebookGraphFilters is only injected with facebookGraphService and grailsApplication - no imports.
Note: I'm using grails 1.3.7 and facebook-graph-0.14 via the Plugin manager from STS (i.e., not directly via github)
I still have the problem that the plugin does not work. I just tried it with a new project, following the steps within the docu and used the javascript from Issue#11 but it does not work. After clicking the Facebook button I get redirected to the page stated in the javascrpt but in the controller I only have a cookie from facebook (fbsr_223390747746...) but session has no facebook entry and facebookGraphService.getFacebookProfile() is null.
Any tips?
Hi,
I'm hitting the exact same issue with Grails 2.0.1 and Facebook-graph plugin 0.14 version. Have you resolved this issue? If yes, can you please point me to the solution.
Thanks, Akhila.
Same problem with Grails 2.1 dammit
P.s. I went through the request and cookies and I can't see any facebook cookies. Dammit!!
Ok... so the problem is not with the plugin, but with our app settings on facebook [at least this is what happened for me]. I was testing my app with localhost, once I've changed that in App settings on facebook, to point to my domain and then I've changed hosts file to point the domain to localhost it started to work fine!
so do you mean change your URL on facebook app to localhost?
2nd part: change the host file to point the domain to localhost??
Sorry i am not getting you, would you mind helping?
I'm sorry, I should have read it before posting ;)
I had my app on facebook configured to use localhost as site url and app domain. For testing purposes. With such configuration, the session.facebook map was always empty.
I've configured my app on facebook, to use a normal domain for site url and app domain. Then I've edited my hosts file on the computer I use for dev, to always point this domain to 127.0.0.1.
Then, instead od using localhost in my browser, I've used this domain. This way everything worked fine.
I hope this makes more sense, if not let me know :)
so i would change my facebook app url: http://localhost:8080/ABC/login/ to http://127.0.0.1:8080/ABC/login/ ?
No, change it from: http://localhost:8080/ABC/login to http://real.domain.com/ABC/login [I'm not sure why would you need the /login part ;) ]
Then edit your hosts file [/etc/hosts] and add: 127.0.0.1 real.domain.com
Don't forget to add real.domain.com as app domain on facebook.
Then, start your app and browse to http://real.domain.com/ABC/login
That's it