How to fetch Facebook UserName, Email, phoneno etc from Facebook Authentication for Spring Security in Grails -


i using spring security core plugin authentication purpose , facebook authentication spring security facebook login purpose. fb login works fine spring security plugin. have issue on that. how can fetch username, email, phoneno etc of facebook user can save db.

here spring security core person.groovy domain class file ...

class person {  transient springsecurityservice  string realname string username string password boolean enabled boolean accountexpired boolean accountlocked boolean passwordexpired byte[] avatar string avatartype     ...... more code ........... } 

here can see added more fields realname(for saving facebook user name), avatar(for saving facebook user profile image) etc. right username saving facebook_100003641451723. want real name of user can save realname field. idea how can ??

update :

i found 1 solution on there grails facebook login using spring security - how know logged in user name

but don't know put code ...

void oncreate(facebookuser user, facebookauthtoken token) {   facebook facebook = new facebooktemplate(token.accesstoken.accesstoken)   facebookprofile fbprofile = facebook.useroperations().userprofile    //fill name   //fieldname ('fullname' @ example)   user.realname = fbprofile.name  } 

update :

now created new service running grails create-service facebookauthservice , facebookauthservice.groovy created inside services/groovypublish/facebookauthservice.groovy there..

here facebookauthservice.groovy file ..

package groovypublish  import org.grails.twitter.person import com.the6hours.grails.springsecurity.facebook.facebookauthtoken   class facebookauthservice {     def servicemethod() {     }     void oncreate(person user, facebookauthtoken token) {    facebook facebook = new facebooktemplate(token.accesstoken.accesstoken)    facebookprofile fbprofile = facebook.useroperations().userprofile     //fill name    //fieldname ('fullname' @ example)    user.realname = fbprofile.name   }    } 

and put dependencies in buildconfig.groovy file ....

dependencies {     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.       runtime 'mysql:mysql-connector-java:5.1.22'      compile 'org.springframework.social:spring-social-core:1.0.1.release'      compile 'org.springframework.social:spring-social-facebook:1.0.1.release' } 

now when start grails application grails run-app showing error

     c:\users\shreshtt\workspace\groovypublish\grails-app\services\groovypublish\facebookauthservice.groovy: 14: unable resolve class facebook @ line 14, column 12.  facebook facebook = new facebooktemplate(token.accesstoken.accesstoken)           ^       c:\users\shreshtt\workspace\groovypublish\grails-app\services\groovypublish\facebookauthservice.groovy: 14: unable resolve class facebooktemplate @ line 14, column 23.  facebook facebook = new facebooktemplate(token.accesstoken.accesstoken)                      ^       c:\users\shreshtt\workspace\groovypublish\grails-app\services\groovypublish\facebookauthservice.groovy: 15: unable resolve class facebookprofile @ line 15, column 19.  facebookprofile fbprofile = facebook.useroperations().userprofile                  ^   3 errors 

you have put implementation of facebookauthservice.

just create service such name, , add method oncreate code (or similar). , don't forget ot add spring social facebook dependency


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -