Its a grails project,
Facebook authentication is successful via oauth,
Now when it comes back to my controller, I want to get emailID of the logged in user,
Searched a lot, but did not find proper documentation,
I am using scribe and have following code in Config.groory
import org.scribe.builder.api.FacebookApi
oauth {
providers {
facebook {
api = FacebookApi
key = 'xxxx'
secret = 'yyyy'
callback = "http://my-domain-name-here:8080/TestOAuth2/dashBoard/facebooklogin"
successUri = "http://my-domain-name-here:8080/TestOAuth2/dashBoard/success"
}
}
}
Any help much appreciated.
Thanks.
Email is not part of a Facebook public_profile. The only way to get the users e-mail address is to request extended permissions on the email field. You can do this by adding a scope to the oauth provider.
config.groovy
As an example of how to return
email
andvarious public_profile fields
please see below. Take Note of:getFacebookResource
params e.g.https://graph.facebook.com/me?fields=id,name,verified,age_range,email"
public_profile (Default)
A person's public profile refers to the following properties on the user object by default:
Try this..,.
Config:
MyController:
You can get working example from my git repo. Grails Oauth Plugin Demo.