@Override public UserSession loadSession(String userName, String password) throws RemoteException { Map<String, String> parameters = Maps.newHashMap(); parameters.put("client_id", userName); parameters.put("client_secret", password); ClientResponse response = doRequest(new RemotingContext(true), "token", parameters, "", REQUEST_MODE.POST); try { OauthToken token = new JsonRestResponseHandler().deserialize(OauthToken.class, response.getEntityInputStream()); return new UserSessionImpl(token.getSessionId(), token.getOauthToken(), null, null); } catch(RestException e) { throw new RemoteException("Unable to retrieve authentication token", e); } finally { response.close(); } } }