From 73bbfaead31e6951543f72e5363bd5e493bb7a93 Mon Sep 17 00:00:00 2001 From: Martin Vogel <martin.vogel@sinc.de> Date: Fri, 17 Jun 2022 14:33:41 +0200 Subject: [PATCH] #414 Add all scopes to the token request --- .../de/fitko/fitconnect/impl/auth/DefaultOAuthService.java | 5 ++++- .../java/fitconnect/impl/auth/OAuthTokenIntegrationTest.java | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/impl/src/main/java/de/fitko/fitconnect/impl/auth/DefaultOAuthService.java b/impl/src/main/java/de/fitko/fitconnect/impl/auth/DefaultOAuthService.java index 3d808799a..754a71de4 100644 --- a/impl/src/main/java/de/fitko/fitconnect/impl/auth/DefaultOAuthService.java +++ b/impl/src/main/java/de/fitko/fitconnect/impl/auth/DefaultOAuthService.java @@ -39,9 +39,12 @@ public class DefaultOAuthService implements OAuthService { put("grant_type", "client_credentials"); put("client_id", clientId); put("client_secret", clientSecret); + }}; - Arrays.stream(scope).forEach(s -> data.put("scope", s)); + if(scope.length > 0){ + data.put("scope", String.join(",", scope)); + } return data.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(joining("&")); } diff --git a/impl/src/test/java/fitconnect/impl/auth/OAuthTokenIntegrationTest.java b/impl/src/test/java/fitconnect/impl/auth/OAuthTokenIntegrationTest.java index 6a1e90e80..70413581b 100644 --- a/impl/src/test/java/fitconnect/impl/auth/OAuthTokenIntegrationTest.java +++ b/impl/src/test/java/fitconnect/impl/auth/OAuthTokenIntegrationTest.java @@ -20,13 +20,14 @@ class OAuthTokenIntegrationTest { var tokenUrl = "https://auth-testing.fit-connect.fitko.dev/token"; var clientId = "781f6213-0f0f-4a79-9372-e7187ffda98b"; var secret = "PnzR8Vbmhpv_VwTkT34wponqXWK8WBm-LADlryYdV4o"; - var scope = "send:region:DE"; + var scope1 = "send:region:DE"; + var scope2 = "send:region:EN"; var authService = new DefaultOAuthService( new RestTemplate(), tokenUrl); final Sender sender = new SubmissionSender(authService, null, null, null); // When - Optional<OAuthToken> token = sender.retrieveOAuthToken(clientId, secret, scope); + Optional<OAuthToken> token = sender.retrieveOAuthToken(clientId, secret, scope1,scope2); // Then assertTrue(token.isPresent()); -- GitLab