From 2ec29701a1422145e55c075c47bde243a1241546 Mon Sep 17 00:00:00 2001 From: shamalka Date: Fri, 17 Jul 2020 23:52:25 +0530 Subject: [PATCH] Fix get default token issues --- .../mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java | 2 +- .../entgra/ui/request/interceptor/DefaultTokenHandler.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 4df23a511b5..a4ca3f026d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -1338,7 +1338,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @GET @Path("/{clientId}/{clientSecret}/default-token") @Override - public Response getDefaultToken(String clientId, String clientSecret) { + public Response getDefaultToken(@PathParam("clientId") String clientId, @PathParam("clientSecret") String clientSecret) { JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService(); try { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java index a500c0027be..1cff1d9d114 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/DefaultTokenHandler.java @@ -104,10 +104,10 @@ public class DefaultTokenHandler extends HttpServlet { newDefaultAuthData.setClientId(clientId); newDefaultAuthData.setClientSecret(clientSecret); - String defaultToken = jTokenResultAsJsonObject.get("access_token").getAsString(); + String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); newDefaultAuthData.setAccessToken(defaultToken); - newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); + newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken));