Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. HttpClient httpclient = HttpClientBuilder.create().build();
  2.  
  3. /* Assemble the login request URL */
  4. String loginURL = LOGINURL +
  5. GRANTSERVICE +
  6. "&client_id=" + CLIENTID +
  7. "&client_secret=" + CLIENTSECRET +
  8. "&username=" + USERNAME +
  9. "&password=" + PASSWORD;
  10. /* POST Login requests */
  11. HttpPost httpPost = new HttpPost(loginURL);
  12.  
  13. HttpResponse response = null;
  14. /* Execute the login POST request */
  15. response = httpclient.execute(httpPost);
  16. /* verify response is HTTP OK */
  17. final int statusCode = response.getStatusLine().getStatusCode();
  18. if (statusCode != HttpStatus.SC_OK)
  19. {
  20. System.out.println("Error authenticating to Force.com: " + statusCode);
  21. // Error is in EntityUtils.toString(response.getEntity())
  22. return;
  23. }
  24.  
  25. HttpResponseProxy {
  26. HTTP / 1.1 200 OK
  27. [
  28. Date : Fri, 21 Oct 2016 10 : 12 : 38 GMT,
  29. Strict - Transport - Security : max - age = 31536000;
  30. includeSubDomains,
  31. Set - Cookie : BrowserId = 3A1ryE8eQa6O - AqbTHyJqQ;
  32. Path = /;
  33. Domain=.salesforce.com;Expires=Tue, 20-Dec-2016 10:12:38 GMT,
  34. Expires: Thu, 01 Jan 1970 00:00:00 GMT,
  35. Pragma: no-cache,
  36. Cache-Control: no-cache,
  37. no-store,
  38. X-ReadOnlyMode: false,
  39. Content-Type: application/json;
  40. charset = UTF - 8,
  41. Transfer - Encoding : chunked
  42. ]
  43. org.apache.http.client.entity.DecompressingEntity @ 892d68
  44. }
  45.  
  46. HttpResponseProxy {
  47. HTTP / 1.1 400 Bad Request
  48. [
  49. Date : Fri, 21 Oct 2016 10 : 22 : 05 GMT,
  50. Strict - Transport - Security : max - age = 31536000;
  51. includeSubDomains,
  52. Set - Cookie : BrowserId = tbJli6t8SyCbA6I8eA0vow;
  53. Path = /;
  54. Domain=.salesforce.com;Expires=Tue, 20-Dec-2016 10:22:05 GMT,
  55. Expires: Thu, 01 Jan 1970 00:00:00 GMT,
  56. Pragma: no-cache,
  57. Cache-Control: no-cache,
  58. no-store,
  59. X-ReadOnlyMode: false,
  60. Content-Type: application/json;
  61. charset = UTF - 8,
  62. Transfer - Encoding : chunked
  63. ]
  64. ResponseEntityProxy {
  65. [
  66. Content - Type : application / json;
  67. charset = UTF - 8, Chunked : true
  68. ]
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement