I am using spring-security-oauth-facebook:0.1 grails plugin in my application.Now i want to access person's email id but i am not able each time facebook server respond 1829812989120 for socialId ,Username, profileId and there is no option of email in returning Map object.Why it is happening.
oauth {
debug = true
providers {
facebook {
api = org.scribe.builder.api.FacebookApi
key = 'my-app-key'
secret = 'secret-key'
successUri = '/oauth/facebook/success'
failureUri = '/oauth/facebook/failure'
callback = "${baseURL}/oauth/facebook/callback"
scopes = "['public_profile','email','name','user']"
}
def sessionKey = oauthService.findSessionKeyForAccessToken(provider)
if (!session[sessionKey]) {
log.warn "No OAuth token in the session for provider '${provider}'"
throw new OAuthLoginException("Authentication error for provider '${provider}'")
}
// Create the relevant authentication token and attempt to log in.
OAuthToken oAuthToken = springSecurityOAuthService.createAuthToken(provider,
session[sessionKey])
println "oAuthToken.principal = "+oAuthToken.principal.toString();
println "oAuthToken.socialId = "+oAuthToken.socialId;
println "oAuthToken.properties= "+oAuthToken.properties
println "oAuthToken.properties= "+oAuthToken.name
println "oAuthToken.properties= "+oAuthToken.toString();
1)I ckecked all println value email is not there. please help me how to get email address of logged in user.
Use this code after session created
OAuthToken oAuthToken = springSecurityOAuthService.createAuthToken(provider,
session[sessionKey])
Token facebookAccessToken = (Token) session[oauthService.findSessionKeyForAccessToken('facebook')]
println "Facebook token :"+facebookAccessToken
def facebookResource = oauthService.getFacebookResource(facebookAccessToken , "https://graph.facebook.com/me")
def facebookResponse = JSON.parse(facebookResource?.getBody())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With