@@ -44,7 +44,8 @@ public RedirectView exchangeCodeForToken(
4444 String oAuthToken ,
4545 DSConfiguration configuration ,
4646 Session session ,
47- String redirect ) throws Exception {
47+ String redirect ,
48+ List <String > scopes ) throws Exception {
4849 String requestBody = buildRequestBody (oAuthToken );
4950 String authHeader = generateAuthHeader (configuration );
5051
@@ -59,7 +60,7 @@ public RedirectView exchangeCodeForToken(
5960 HttpResponse <String > response = client .send (request , HttpResponse .BodyHandlers .ofString ());
6061
6162 if (response .statusCode () == 200 ) {
62- processTokenResponse (response .body (), configuration , session );
63+ processTokenResponse (response .body (), configuration , session , scopes );
6364 } else {
6465 throw new IOException ("Failed to exchange code for token. Status code: " + response .statusCode ());
6566 }
@@ -79,7 +80,8 @@ private String generateAuthHeader(DSConfiguration configuration) {
7980 (configuration .getUserId () + ":" + configuration .getSecretUserId ()).getBytes (StandardCharsets .UTF_8 ));
8081 }
8182
82- private void processTokenResponse (String responseBody , DSConfiguration configuration , Session session )
83+ private void processTokenResponse (String responseBody , DSConfiguration configuration , Session session ,
84+ List <String > scopes )
8385 throws Exception {
8486 ApiClient apiClient = new ApiClient (configuration .getBasePath ());
8587 String accessToken = SecurityHelpers .parseJsonField (responseBody , "access_token" );
@@ -88,7 +90,7 @@ private void processTokenResponse(String responseBody, DSConfiguration configura
8890 OAuth .UserInfo userInfo = apiClient .getUserInfo (accessToken );
8991 String accountId = userInfo .getAccounts ().size () > 0 ? userInfo .getAccounts ().get (0 ).getAccountId () : "" ;
9092
91- SecurityHelpers .setSpringSecurityAuthentication (SecurityHelpers . getScopeList () , accessToken , userInfo ,
93+ SecurityHelpers .setSpringSecurityAuthentication (scopes , accessToken , userInfo ,
9294 accountId , session ,
9395 expiresIn );
9496 }
0 commit comments