keycloak-uncached
Changes
social/facebook/pom.xml 5(+5 -0)
Details
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 6e5e832..ddc25d5
--- a/docbook/reference/en/en-US/modules/social-facebook.xml
+++ b/docbook/reference/en/en-US/modules/social-facebook.xml
@@ -18,7 +18,8 @@
         </listitem>
         <listitem>
             <para>
-                Once the app has been created click on <literal>Settings</literal> in sidebar on the left. Then click
+                Once the app has been created click on <literal>Settings</literal> in sidebar on the left. You must specify
+                a contact email.  Save your changes.  Then click
                 on <literal>Advanced</literal>. Under <literal>Security</literal> make sure
                 <literal>Client OAuth Login</literal> is enabled. In <literal>Valid OAuth redirect URIs</literal> insert
                 the <link linkend="social-callbackurl">social callback url</link>. Scroll down and click on the
@@ -28,7 +29,8 @@
         <listitem>
             <para>
                 Click <literal>Status & Review</literal> and select <literal>YES</literal> for <literal>Do you want
-                to make this app and all its live features available to the general public?</literal>.
+                to make this app and all its live features available to the general public?</literal>.  You will
+                not be able to set this until you have provided a contact email in the general settings of this application.
             </para>
         </listitem>
         <listitem>
                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 66f0d83..f6afdc6
--- a/docbook/reference/en/en-US/modules/social-twitter.xml
+++ b/docbook/reference/en/en-US/modules/social-twitter.xml
@@ -22,7 +22,7 @@
         </listitem>
         <listitem>
             <para>
-                Now click <literal>Details</literal>. Copy <literal>Consumer key</literal> and <literal>Consumer secret</literal> from the
+                Now click <literal>API Keys</literal> tab. Copy <literal>API key</literal> and <literal>API secret</literal> from the
                 <ulink url="https://dev.twitter.com/apps">Twitter Developer Console</ulink> into the settings
                 page in the Keycloak Admin Console as the <literal>Key</literal> and <literal>Secret</literal>. Then click
                 <literal>Save</literal> in the Keycloak Admin Console to enable login with Twitter.
                social/facebook/pom.xml 5(+5 -0)
diff --git a/social/facebook/pom.xml b/social/facebook/pom.xml
index 8d55bc0..39b076f 100755
--- a/social/facebook/pom.xml
+++ b/social/facebook/pom.xml
@@ -25,5 +25,10 @@
             <artifactId>jackson-mapper-asl</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.jboss.logging</groupId>
+            <artifactId>jboss-logging</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 </project>
                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 4f15fbb..f8b5ded 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 <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
  */
 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) {