Grails facebook spring security returning null

I am using ":spring-security-facebook:0.17" integrated with ":spring-security-core:2.0-RC5". I have implemented facebookAuthService.groovy for customization. But the token is not authenticated and the fbProfile is returning null except id and name.

FacebookUser create(FacebookAuthToken token) {"Create domain for facebook user $token.uid")

    //Use Spring Social Facebook to load details for current user from Facebook API
    Facebook facebook = new FacebookTemplate(token.accessToken.accessToken)
    FacebookProfile fbProfile = facebook.userOperations().userProfile
    FacebookProfile fbProfile2 = facebook.userOperations().getUserProfile()
    def ff = facebook.userOperations().userPermissions
    String email =
    String username = fbProfile.username
    String firstName = fbProfile.firstName
    String lastName = fbProfile.lastName

    println fbProfile as JSON
    println token as JSON

    User person = new User(
            username: 'jgf',
            password: token.accessToken.accessToken, //not really necessary
            enabled: true,
            accountExpired:  false,
            accountLocked: false,
            passwordExpired: false,

            //fill with data loaded from Facebook API
            email: email
    ) true)
    UserRole.create(person, AuthRole.findByAuthority('ROLE_USER'))
    UserRole.create(person, AuthRole.findByAuthority('ROLE_FACEBOOK'))
    FacebookUser fbUser = new FacebookUser(
            uid: token.uid,
            accessToken: token.accessToken.accessToken,
            accessTokenExpires: token.accessToken.expireAt,
            user: person
    ) true)
    return fbUser

The response is as below: access token:


and fbProfile:

{"about":null,"bio":null,"birthday":null,"class":"","education":null,"email":null,"favoriteAtheletes":null,"favoriteTeams":null,"firstName":null,"gender":null,"hometown":null,"id":"1026180034068785","inspirationalPeople":null,"interestedIn":null,"languages":null,"lastName":null,"link":null,"locale":null,"location":null,"middleName":null,"name":"Sanjib Maharjan","political":null,"quotes":null,"relationshipStatus":null,"religion":null,"significantOther":null,"sports":null,"thirdPartyId":null,"timezone":null,"updatedTime":null,"username":null,"website":null,"work":null}

The problem here is everything is null and i could not figure out why.

PS:All the facebook credential are correct and permissions are also provided(public_profile, email and user_about_me). Is is because the token is not authenticated or is there some other thing that i am missing.Any help is appreciated.Thank you.


I finally figured out why everything is null except name and id.

Facebook have changed the api since July 8th, 2015 - API version 2.4 :

and according to that we have to specify each field and edge you want to get returned, e.g.,name,email,firstname

facebook.userOperations().getUserProfile() is providing null fields except id and name.So the solution is to use different api that allows to set fields or we can do it manually by hitting the uri(,name,email,firstname).

Need Your Help

Add to existing older slideshow script to include a caption for images

javascript html arrays slideshow caption

I'm wondering if there is a small change or addition I could make to the existing script, to add captions for images in my slideshow, or if I really should just abandon this old script and start fr...

Importing CSV to SQL Server CE SDF

c# sql-server csv windows-ce

I am trying to import a csv file into an SQL sever CE sdf database in a c# mvc3 web app. I understand that I need to read the csv file first and then transfer the file line by line into the sql dat...