Facebook Email Access in Spring Boot Social Showcase

We’ve been investigating the Spring Social Showcase app for Spring Boot as we prepare to add OAUTH support to NixMash Spring. We saw in the previous post how the Showcase App’s Facebook Profile Page was missing a rather important Facebook User Profile property, the user’s email. I mentioned in that post that I assumed it was a permissions issue in my Facebook Profile Setup. Turns out that wasn’t the case at all.

What we want to see on the Showcase Profile page.

Make Facebook App Public

Before getting into the code portion of our post, it’s important to remember to complete your Facebook Application setup by making the app publicly available. You do that by providing a contact email on your Facebook Application Dashboard along with performing a couple of other clicks you’ll find on these screenshots.

Add Email to the Facebook Login Scope

Facebook uses a variety of Login Scopes to determine what a user can do with Facebook services beyond the default permissions. What is interesting is that default Facebook permissions DO include email access according to the Facebook documentation. We should be able to access the user email property without explicitly adding an email scope, but turns out we still need to add it to the Login Scope for our Spring Social /connect/facebook/[POST] action.

Once we’ve added “email” to the Scope we’ll see the Facebook Permissions dialog next time we authenticate with Facebook.

Profile.email Thymeleaf variable update

One final step is to update the Thymeleaf variable in the HTML to read ${profile.email} on the Showcase Facebook Profile Display Page. Out-of-the-box the HTML variable reads ${email}.