From: Kai Moritz Date: Tue, 29 Oct 2019 18:18:53 +0000 (+0100) Subject: 190: Access token expired X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8079d646addc5206f64bfb213d018a2fa94444d3;p=facebook-errors 190: Access token expired --- diff --git a/src/main/java/de/juplo/facebook/errors/AccessTokenExpiredException.java b/src/main/java/de/juplo/facebook/errors/AccessTokenExpiredException.java new file mode 100644 index 0000000..dfe53f5 --- /dev/null +++ b/src/main/java/de/juplo/facebook/errors/AccessTokenExpiredException.java @@ -0,0 +1,26 @@ +package de.juplo.facebook.errors; + + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; + + + + +/** + * 190: Bad signature (access token expired!). + * As of Octobre 2019 the {@link https://developers.facebook.com/docs/graph-api/using-graph-api/error-handling/ Documentation } + * says "Access token has expired. Get a new access token." for code 190. + * @author Kai Moritz + */ +public class AccessTokenExpiredException extends OAuthException +{ + protected AccessTokenExpiredException( + HttpStatus status, + HttpHeaders headers, + FacebookErrorMessage error + ) + { + super(status, headers, error); + } +} diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiException.java b/src/main/java/de/juplo/facebook/errors/GraphApiException.java index 31c23dc..1b7eaaa 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiException.java @@ -91,6 +91,7 @@ public class GraphApiException extends RuntimeException case 100: return new UnsupportedGetRequestException(status, headers, error); case 102: return new UserAccessTokenRequiredException(status, headers, error); case 104: return new AccessTokenRequiredException(status, headers, error); + case 190: return new AccessTokenExpiredException(status, headers, error); // 200..299: permission errors case 200: case 201: diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java index 2e03df7..c9a53cd 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiErrorHandlerTest.java @@ -254,6 +254,28 @@ public class GraphApiErrorHandlerTest } } + @Test + public void testError190() + { + log.info("testError190"); + + requestFactory.setBody("{\"error\":{\"message\":\"Bad signature\",\"type\":\"OAuthException\",\"code\":190,\"fbtrace_id\":\"Ay2OYQrINbXOCfQpBvoxDIw\"}}"); + + try + { + clientTemplate.getForObject("ANY", SOME.class); + fail("The expected exception was not thrown"); + } + catch(AccessTokenExpiredException e) + { + log.debug("{}", e.toString()); + assertEquals(new Integer(190), e.getCode()); + assertEquals("Bad signature", e.getMessage()); + assertEquals(Type.OAuthException, e.getType()); + assertEquals("Ay2OYQrINbXOCfQpBvoxDIw", e.getTraceId()); + } + } + @Test public void testError613() {