Spring social - can't get email address from fetched profile

oauth
api
spring

#1

I’m trying to add “Sign in with Twitter” thing to my web application.
I configured spring security and social and everything works i.e. I can fetch user name, access key, access secret etc., but when I want to get user email from fetched profile I’m getting null.

My code inside of controller (spring redirect to this after successful authorization) looks like this:

Connection<A> connection = providerSignInUtils.getConnectionFromSession(request);   
String email = connection.fetchUserProfile().getEmail();

I know you have to whitelist application, check “Request email addresses from users” field, refresh user’s access tokens etc. I did that all already and still getting null. I’m out of ideas what to do, I tried “/auth/twitter?scope=email” instead of “/auth/twitter” trick but does not work. Maybe it’s something wrong with Spring? I’m using newest spring-social 1.1.4 with spring twitter API 1.1.2.

I saw many question about this issue but all of them were from 2011/2012, AFAIK Twitter didn’t support fetching email address from user back then, but it changed, however it still doesn’t seem to work properly.


#2

Not sure whether this issue on spring-social-twitter is helpful?


#3

Seems like a solution for me, but I don’t really know how can I implement this to my application. As I wrote in linked topic TwitterAdapter (which has invalid method) need to be changed, but it is not possible since it is a .class file inside spring-social library. Any ideas?


#4

Here is also the open GitHub ticket for Twitter email