throw redirect;
}
- DefaultOAuth2AccessToken token = null;
+ /**
+ * Extract additional information and store it in the token
+ * See:
+ * https://developers.facebook.com/docs/reference/login/signed-request/
+ * TODO:
+ * - Attribute "code"
+ */
+ Map<String,Object> additionalInformation = new HashMap<>();
try
{
- String value = json.get("oauth_token").asText();
- if (value.isEmpty())
- {
- log.error("field \"oauth_token\" is missing: {}", data);
- throw redirect;
- }
- token = new DefaultOAuth2AccessToken(value);
- token.setExpiration(new Date(json.get("expires").getLongValue()*1000L));
-
- /**
- * Extract additional information and store it in the token
- * See:
- * https://developers.facebook.com/docs/reference/login/signed-request/
- * TODO:
- * - Attribute "code"
- */
- Map<String,Object> additionalInformation = new HashMap<>();
additionalInformation.put(
"issued_at",
new Date(json.get("issued_at").getLongValue()*1000L)
);
- additionalInformation.put(
- "user_id",
- json.get("user_id").asText()
- );
Map<String,Object> user = new HashMap<>();
user.put(
"country",
page.put("admin", json.get("page").get("admin").asBoolean());
additionalInformation.put("page", page);
}
+ }
+ catch (NullPointerException e)
+ {
+ log.warn("expected additional data is missing: {}", data);
+ }
+
+ DefaultOAuth2AccessToken token = null;
+ try
+ {
+ String value = json.get("oauth_token").asText();
+ if (value.isEmpty())
+ {
+ log.error("field \"oauth_token\" is missing: {}", data);
+ throw redirect;
+ }
+ token = new DefaultOAuth2AccessToken(value);
+ token.setExpiration(new Date(json.get("expires").getLongValue()*1000L));
+
+ additionalInformation.put(
+ "user_id",
+ json.get("user_id").asText()
+ );
+
token.setAdditionalInformation(additionalInformation);
}
catch (NullPointerException e)
--- /dev/null
+package de.juplo.facebook;
+
+
+import java.util.Map;
+import org.springframework.security.oauth2.client.resource.UserRedirectRequiredException;
+
+
+
+/**
+ *
+ * @author kai
+ */
+public class SignedRequestAwareUserRedirectRequiredException
+ extends
+ UserRedirectRequiredException
+{
+ private final Map<String,Object> signedRequestData;
+
+
+ public SignedRequestAwareUserRedirectRequiredException(
+ String redirectUri,
+ Map<String,String> requestParams,
+ Map<String,Object> signedRequestData
+ )
+ {
+ super(redirectUri, requestParams);
+ this.signedRequestData = signedRequestData;
+ }
+
+
+ public Map<String, Object> getSignedRequestData()
+ {
+ return signedRequestData;
+ }
+}