code: @POST
    @Path("refresh")
    @Consumes(MediaType.APPLICATION_JSON)
    public Response refreshAccessToken(RefreshTokenRequest refreshToken) {
      // Perform all validation here to control the exact error message returned to comply with the Oauth2 standard
  
      if (null == refreshToken.getRefresh_token() ||
          null == refreshToken.getGrant_type()) {
        throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request"));
      }
  
      if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) {
        // Unsupported grant type
        throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type"));
      }
  
      DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token());
      if (null == connection) {
        throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant"));
      }
  
      // Invalidate the old cache key
      connectionDao.invalidateCacheKey(connection.getAccessToken());
  
      connection.setAccessToken(accessTokenGenerator.generate());
      connection.setExpireTime(calculateExpirationDate(tokenExpiresIn));
  
      connectionDao.putWithCacheKey(connection.getAccessToken(), connection);
  
      return Response.ok(ImmutableMap.builder()
          .put("access_token", connection.getAccessToken())
          .put("refresh_token", connection.getRefreshToken())
          .put("expires_in", tokenExpiresIn)
          .build())
          .cookie(createCookie(connection.getAccessToken(), tokenExpiresIn))
          .build();
  
    }
docs: Refresh an access_token using the refresh token
  
  @param refreshToken refresh token
  @return @return access_token and refresh token if successful.
  Success response http://tools.ietf.org/html/rfc6749#section-5.1
  Failure response http://tools.ietf.org/html/rfc6749#section-5.2