/** * Authenticate */ public void authenticate() { HttpURLConnection urlConnection = new ConnBuilder(apiEndpoint) .addHeader(AUTH_HEADER, username) .addHeader(AUTH_KEY_HEADER, apiKey) .getConnection(); Response response = doAuthOperation(urlConnection); if (response.isSuccessCode()) { credentials = new Credentials( response.getHeader(STORAGE_TOKEN_HEADER), response.getHeader(STORAGE_URL_HEADER) ); log.trace("Authentication successful"); } else { throw new IllegalStateException("Error authenticating to the service. Please check your credentials. Code = " + response.code); } }
/** * Authenticate */ public void authenticate() { HttpURLConnection urlConnection = new ConnBuilder(apiEndpoint) .addHeader(AUTH_HEADER, username) .addHeader(AUTH_KEY_HEADER, apiKey) .getConnection(); Response response = doAuthOperation(urlConnection); if (response.isSuccessCode()) { credentials = new Credentials( response.getHeader(STORAGE_TOKEN_HEADER), response.getHeader(STORAGE_URL_HEADER) ); log.trace("Authentication successful"); } else { throw new IllegalStateException("Error authenticating to the service. Please check your credentials. Code = " + response.code); } }