Announcement Announcement Module
No announcement yet.
Facebook OAuth dialog access email Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Facebook OAuth dialog access email

    I am trying to access the user's email from in Spring social sample but the email is always null. On Facebook developer pages it says "you should specify the additional permissions you require using the scope parameter."

    There is a setting for authenticated referrals but I didn't see any place to set it for normal Facebook login. Is this passed on client side. If so how do I do it with spring social?

    	@RequestMapping(value="/signup", method=RequestMethod.GET)
    	public SignupForm signupForm(WebRequest request, Model model) {
    		Connection<?> connection = ProviderSignInUtils.getConnection(request);
    		if (connection != null) {
    			UserProfile profile = connection.fetchUserProfile();
    			System.out.println("user email is "+profile.getEmail());
    			System.out.println("user name is "+profile.getFirstName() +", "+ profile.getLastName());
    			return SignupForm.fromProviderUser(connection.fetchUserProfile());
    		} else {
    			return new SignupForm();

  • #2

    You can do this by passing a "scope" parameter with the POST submission to the ProviderSignInController or ConnectController - the form submission that happens when the user clicks the button to signin or connect with Facebook.

    The spring-social-quickstart sample application has this parameter set, see

    <form action="<c:url value="/signin/facebook" />" method="POST">
    <button type="submit">Sign in with Facebook</button>
    <input type="hidden" name="scope" value="email,publish_stream,offline_access" />

    You'll see here the "scope" parameter contains a scope of email as one of the requested scopes, enabling the Facebook to include the email permission as one of the permissions that the user must authorize.

    Hope this helps,