Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpClient httpclient = HttpClientBuilder.create().build();
- /* Assemble the login request URL */
- String loginURL = LOGINURL +
- GRANTSERVICE +
- "&client_id=" + CLIENTID +
- "&client_secret=" + CLIENTSECRET +
- "&username=" + USERNAME +
- "&password=" + PASSWORD;
- /* POST Login requests */
- HttpPost httpPost = new HttpPost(loginURL);
- HttpResponse response = null;
- /* Execute the login POST request */
- response = httpclient.execute(httpPost);
- /* verify response is HTTP OK */
- final int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != HttpStatus.SC_OK)
- {
- System.out.println("Error authenticating to Force.com: " + statusCode);
- // Error is in EntityUtils.toString(response.getEntity())
- return;
- }
- HttpResponseProxy {
- HTTP / 1.1 200 OK
- [
- Date : Fri, 21 Oct 2016 10 : 12 : 38 GMT,
- Strict - Transport - Security : max - age = 31536000;
- includeSubDomains,
- Set - Cookie : BrowserId = 3A1ryE8eQa6O - AqbTHyJqQ;
- Path = /;
- Domain=.salesforce.com;Expires=Tue, 20-Dec-2016 10:12:38 GMT,
- Expires: Thu, 01 Jan 1970 00:00:00 GMT,
- Pragma: no-cache,
- Cache-Control: no-cache,
- no-store,
- X-ReadOnlyMode: false,
- Content-Type: application/json;
- charset = UTF - 8,
- Transfer - Encoding : chunked
- ]
- org.apache.http.client.entity.DecompressingEntity @ 892d68
- }
- HttpResponseProxy {
- HTTP / 1.1 400 Bad Request
- [
- Date : Fri, 21 Oct 2016 10 : 22 : 05 GMT,
- Strict - Transport - Security : max - age = 31536000;
- includeSubDomains,
- Set - Cookie : BrowserId = tbJli6t8SyCbA6I8eA0vow;
- Path = /;
- Domain=.salesforce.com;Expires=Tue, 20-Dec-2016 10:22:05 GMT,
- Expires: Thu, 01 Jan 1970 00:00:00 GMT,
- Pragma: no-cache,
- Cache-Control: no-cache,
- no-store,
- X-ReadOnlyMode: false,
- Content-Type: application/json;
- charset = UTF - 8,
- Transfer - Encoding : chunked
- ]
- ResponseEntityProxy {
- [
- Content - Type : application / json;
- charset = UTF - 8, Chunked : true
- ]
- }
- }
- SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
- SSLContext.getDefault(),
- new String[] { "SSLv2Hello","SSLv3","TLSv1","TLSv1.1","TLSv1.2"},
- null,
- SSLConnectionSocketFactory.getDefaultHostnameVerifier());
- Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
- .register("http", PlainConnectionSocketFactory.getSocketFactory())
- .register("https", socketFactory)
- .build();
- PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
- CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();
Add Comment
Please, Sign In to add comment