Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEYCLOAK-15167 Retrieve email from Twitter IdP #7539

Merged
merged 1 commit into from Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -47,6 +47,7 @@
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;
Expand Down Expand Up @@ -190,8 +191,7 @@ public Response authResponse(@QueryParam("state") String state,

AuthenticationSessionModel authSession = null;
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()));

IdentityBrokerState idpState = IdentityBrokerState.encoded(state);
Expand All @@ -218,6 +218,7 @@ public Response authResponse(@QueryParam("state") String state,
identity.setIdp(TwitterIdentityProvider.this);

identity.setUsername(twitterUser.getScreenName());
identity.setEmail(twitterUser.getEmail());
identity.setName(twitterUser.getName());


Expand Down
Expand Up @@ -356,7 +356,6 @@ public void githubPrivateEmailLogin() throws InterruptedException {
public void twitterLogin() {
setTestProvider(TWITTER);
performLogin();
assertUpdateProfile(false, false, true);
assertAccount();
}

Expand Down