diff --git a/src/main/java/no/fint/oauth/TokenInstance.java b/src/main/java/no/fint/oauth/TokenInstance.java index ab494cf..4dccc0d 100644 --- a/src/main/java/no/fint/oauth/TokenInstance.java +++ b/src/main/java/no/fint/oauth/TokenInstance.java @@ -16,15 +16,20 @@ @Slf4j @Component -@RequiredArgsConstructor @ConditionalOnProperty(value = "fint.oauth.enabled", havingValue = "true") public class TokenInstance { - private final MultiValueMap formData = createFormData(); private final RestClient oauthRestClient; private final OAuthTokenProps props; + private final MultiValueMap formData; private AuthToken authToken; + public TokenInstance(OAuthTokenProps props, RestClient oauthRestClient) { + this.props = props; + this.oauthRestClient = oauthRestClient; + this.formData = createFormData(); + } + @PostConstruct public void init() { if (ObjectUtils.isEmpty(props.getAccessTokenUri())) { diff --git a/src/main/java/no/fint/oauth/TokenService.java b/src/main/java/no/fint/oauth/TokenService.java index fb73d39..5ba52f0 100644 --- a/src/main/java/no/fint/oauth/TokenService.java +++ b/src/main/java/no/fint/oauth/TokenService.java @@ -32,7 +32,7 @@ public void init() { } private void refreshConnection(String requestUrl) { - ResponseEntity response = oauthRestClient.post() + ResponseEntity response = oauthRestClient.get() .uri(requestUrl) .headers(header -> header.add( HttpHeaders.AUTHORIZATION, BEARER_TOKEN_TEMPLATE.formatted(tokenInstance.getAccessToken())