Merge branch 'new-improvements' into 'master'

Fix issues of getting default token

See merge request entgra/carbon-device-mgt!597
revert-70ac1926
Dharmakeerthi Lasantha 4 years ago
commit 0c2a7fe0dd

@ -1338,7 +1338,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET @GET
@Path("/{clientId}/{clientSecret}/default-token") @Path("/{clientId}/{clientSecret}/default-token")
@Override @Override
public Response getDefaultToken(String clientId, String clientSecret) { public Response getDefaultToken(@PathParam("clientId") String clientId, @PathParam("clientSecret") String clientSecret) {
JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService(); JWTClientManagerService jwtClientManagerService = DeviceMgtAPIUtils.getJWTClientManagerService();
try { try {
JWTClient jwtClient = jwtClientManagerService.getJWTClient(); JWTClient jwtClient = jwtClientManagerService.getJWTClient();

@ -104,10 +104,10 @@ public class DefaultTokenHandler extends HttpServlet {
newDefaultAuthData.setClientId(clientId); newDefaultAuthData.setClientId(clientId);
newDefaultAuthData.setClientSecret(clientSecret); newDefaultAuthData.setClientSecret(clientSecret);
String defaultToken = jTokenResultAsJsonObject.get("access_token").getAsString(); String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString();
newDefaultAuthData.setAccessToken(defaultToken); newDefaultAuthData.setAccessToken(defaultToken);
newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString());
newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString());
httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData);
HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken));

Loading…
Cancel
Save