diff --git a/docbook/reference/en/en-US/modules/social-facebook.xml b/docbook/reference/en/en-US/modules/social-facebook.xml old mode 100644 new mode 100755 index 6e5e832db84..ddc25d5390d --- a/docbook/reference/en/en-US/modules/social-facebook.xml +++ b/docbook/reference/en/en-US/modules/social-facebook.xml @@ -18,7 +18,8 @@ - Once the app has been created click on Settings in sidebar on the left. Then click + Once the app has been created click on Settings in sidebar on the left. You must specify + a contact email. Save your changes. Then click on Advanced. Under Security make sure Client OAuth Login is enabled. In Valid OAuth redirect URIs insert the social callback url. Scroll down and click on the @@ -28,7 +29,8 @@ Click Status & Review and select YES for Do you want - to make this app and all its live features available to the general public?. + to make this app and all its live features available to the general public?. You will + not be able to set this until you have provided a contact email in the general settings of this application. diff --git a/docbook/reference/en/en-US/modules/social-twitter.xml b/docbook/reference/en/en-US/modules/social-twitter.xml old mode 100644 new mode 100755 index 66f0d8307b3..f6afdc66fb6 --- a/docbook/reference/en/en-US/modules/social-twitter.xml +++ b/docbook/reference/en/en-US/modules/social-twitter.xml @@ -22,7 +22,7 @@ - Now click Details. Copy Consumer key and Consumer secret from the + Now click API Keys tab. Copy API key and API secret from the Twitter Developer Console into the settings page in the Keycloak Admin Console as the Key and Secret. Then click Save in the Keycloak Admin Console to enable login with Twitter. diff --git a/social/facebook/pom.xml b/social/facebook/pom.xml index 8d55bc00fb7..39b076f5e3e 100755 --- a/social/facebook/pom.xml +++ b/social/facebook/pom.xml @@ -25,5 +25,10 @@ jackson-mapper-asl provided + + org.jboss.logging + jboss-logging + provided + diff --git a/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java b/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java index 4f15fbbe2b4..f8b5dedb95e 100755 --- a/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java +++ b/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java @@ -1,6 +1,7 @@ package org.keycloak.social.facebook; import org.codehaus.jackson.JsonNode; +import org.jboss.logging.Logger; import org.keycloak.social.AbstractOAuth2Provider; import org.keycloak.social.SocialProviderException; import org.keycloak.social.SocialUser; @@ -10,6 +11,7 @@ import org.keycloak.social.utils.SimpleHttp; * @author Stian Thorgersen */ public class FacebookProvider extends AbstractOAuth2Provider { + protected static final Logger logger = Logger.getLogger(FacebookProvider.class); private static final String ID = "facebook"; private static final String NAME = "Facebook"; @@ -50,10 +52,20 @@ public class FacebookProvider extends AbstractOAuth2Provider { try { JsonNode profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson(); - SocialUser user = new SocialUser(profile.get("id").getTextValue(), profile.get("username").getTextValue()); + + JsonNode id = profile.get("id"); + JsonNode username = profile.get("username"); + JsonNode email = profile.get("email"); + + //logger.info("email is null: " + email == null); + //logger.info("username is null: " + username == null); + + if (username == null) username = email == null ? id : email; + + SocialUser user = new SocialUser(id.getTextValue(), username.getTextValue()); user.setName(profile.has("first_name") ? profile.get("first_name").getTextValue() : null, profile.has("last_name") ? profile.get("last_name").getTextValue() : null); - user.setEmail(profile.has("email") ? profile.get("email").getTextValue() : null); + user.setEmail(profile.has("email") ? email.getTextValue() : null); return user; } catch (Exception e) {