Skip to content

Commit bca0c79

Browse files
authored
fix(generic): don't fail on unknown properties while deserialising RefreshTokenResponse (#1449)
don't fail on unknown properties while deserialising RefreshTokenResponse
1 parent 835e0c5 commit bca0c79

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

extensions/data-transfer/portability-data-transfer-generic/src/main/java/org/datatransferproject/datatransfer/generic/auth/OAuthTokenManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.fasterxml.jackson.annotation.JsonProperty;
77
import com.fasterxml.jackson.core.JsonFactory;
88
import com.fasterxml.jackson.core.JsonParseException;
9+
import com.fasterxml.jackson.databind.DeserializationFeature;
910
import com.fasterxml.jackson.databind.JsonMappingException;
1011
import com.fasterxml.jackson.databind.ObjectMapper;
1112
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
@@ -97,6 +98,7 @@ public OAuthTokenManager(
9798
this.client = client;
9899
this.monitor = monitor;
99100
this.om.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
101+
this.om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
100102
}
101103

102104
private TokensAndUrlAuthData refreshToken() throws IOException {
@@ -157,6 +159,7 @@ public <T, Ex extends Exception> T withAuthData(FunctionRequiringAuthData<T, Ex>
157159
return f.execute(authData);
158160
} catch (InvalidTokenException e) {
159161
if (authData.getRefreshToken() == null || authData.getRefreshToken().isEmpty()) {
162+
monitor.severe(() -> "Refresh token not present with auth data");
160163
throw e;
161164
}
162165

extensions/data-transfer/portability-data-transfer-generic/src/test/java/org/datatransferproject/datatransfer/generic/auth/OAuthTokenManagerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public void testWithAuthDataWithRefreshedRefreshToken() throws Exception {
9494
+ "{"
9595
+ " \"access_token\": \"newAccessToken\","
9696
+ " \"refresh_token\": \"newRefreshToken\","
97-
+ " \"token_type\": \"Bearer\""
97+
+ " \"token_type\": \"Bearer\","
98+
+ " \"some_random_field\": \"some_random_value\""
9899
+ "}"));
99100

100101
TokensAndUrlAuthData usedAuthData =

0 commit comments

Comments
 (0)