Search code examples
facebookgrailsspring-securityfacebook-oauth

Grails Spring security facebook plugin sample FacebookAuthDAOImpl


I started looking at this plugin for facebook integration in grails 2.0 apps. I ran through he setup instructions listed and got a sample app working....for the most part.

I'm having problems fleshing out FacebookAuthDaoImpl which implements the interface FacebookAuthDao. Now I know this class is supposed to be configured to match the apps domain structure, but for a sample app with no out-of-the-ordinary domain settings what would be an appropraite implementation of this interface?

What I'm trying to achieve is when a facebook user is created, a spring security user should also be created and they both be associated.

Edit:

After running s2-init-facebook and getting the generated FacebookAuthDaoImpl. I executed run-app and then I get an error roles in getRoles() of the generated impl.

No such property: roles for class: com.gotomanners.auth.FacebookUser

I fixed this by adding

roles = [new GrantedAuthorityImpl('ROLE_USER'), new GrantedAuthorityImpl('ROLE_FACEBOOK')]

The app starts fine now and I can click the fbConnect button which connects to facebook fine but on returning to the app there is no facebookUser or regular user in the DB .... which is why I went on to look at using createAppUser() from DefaultConnectedFacebookAuthDaoImpl


Solution

  • This plugin has since been updated(0.6.2 at this time of writing) and this issue is now resolved!