KEYCLOAK-15167 Retrieve email from Twitter IdP

This commit is contained in:
Nathan Strobbe 2020-10-28 20:56:09 +01:00 committed by Marek Posolda
parent 0210acadad
commit 64717f650b
2 changed files with 3 additions and 3 deletions

View file

@ -47,6 +47,7 @@ import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.auth.RequestToken;
import twitter4j.conf.ConfigurationBuilder;
import javax.ws.rs.GET;
import javax.ws.rs.QueryParam;
@ -201,8 +202,7 @@ public class TwitterIdentityProvider extends AbstractIdentityProvider<OAuth2Iden
}
try (VaultStringSecret vaultStringSecret = session.vault().getStringSecret(getConfig().getClientSecret())) {
Twitter twitter = new TwitterFactory().getInstance();
Twitter twitter = new TwitterFactory(new ConfigurationBuilder().setIncludeEmailEnabled(true).build()).getInstance();
twitter.setOAuthConsumer(getConfig().getClientId(), vaultStringSecret.get().orElse(getConfig().getClientSecret()));
String twitterToken = authSession.getAuthNote(TWITTER_TOKEN);
@ -217,6 +217,7 @@ public class TwitterIdentityProvider extends AbstractIdentityProvider<OAuth2Iden
identity.setIdp(TwitterIdentityProvider.this);
identity.setUsername(twitterUser.getScreenName());
identity.setEmail(twitterUser.getEmail());
identity.setName(twitterUser.getName());

View file

@ -369,7 +369,6 @@ public class SocialLoginTest extends AbstractKeycloakTest {
public void twitterLogin() {
setTestProvider(TWITTER);
performLogin();
assertUpdateProfile(false, false, true);
assertAccount();
}