Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SOCIALFB-80: Fix for posting exception due to Facebook's changing err…

…or messages.
  • Loading branch information...
commit ff3b11046534e4774680264f4a24b3898ffa14a1 1 parent ebd0e90
Craig Walls authored
View
2  ...book/src/main/java/org/springframework/social/facebook/api/impl/FacebookErrorHandler.java
@@ -121,6 +121,8 @@ void handleFacebookError(HttpStatus statusCode, Map<String, String> errorDetails
throw new InsufficientPermissionException(requiredPermission);
} else if (message.contains("Permissions error")) {
throw new InsufficientPermissionException();
+ } else if (message.contains("The user hasn't authorized the application to perform this action")) {
+ throw new InsufficientPermissionException();
} else {
throw new OperationNotPermittedException(message);
}
View
16 ...ial-facebook/src/test/java/org/springframework/social/facebook/api/ErrorHandlingTest.java
@@ -55,7 +55,21 @@ public void insufficientPrivileges() {
assertEquals("rsvp_event", e.getRequiredPermission());
}
}
-
+
+ @Test
+ public void userHasntAuthorized() {
+ try {
+ mockServer.expect(requestTo("https://graph.facebook.com/me/feed"))
+ .andExpect(method(POST))
+ .andExpect(header("Authorization", "OAuth someAccessToken"))
+ .andRespond(withResponse(jsonResource("testdata/error-user-hasnt-authorized"), responseHeaders, HttpStatus.FORBIDDEN, ""));
+ facebook.feedOperations().postLink("Test message", new FacebookLink("http://test.com", "Test", "Test this", "Testing some stuff"));
+ fail();
+ } catch (InsufficientPermissionException e) {
+ assertEquals("Insufficient permission for this operation.", e.getMessage());
+ }
+ }
+
@Test
public void notAFriend() {
try {
View
1  ...st/java/org/springframework/social/facebook/api/testdata/error-user-hasnt-authorized.json
@@ -0,0 +1 @@
+{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}
Please sign in to comment.
Something went wrong with that request. Please try again.