Forum Stats

  • 3,733,347 Users
  • 2,246,745 Discussions


HTTPS Rest Call using Jersey 2.4 to LinkedIn Rest Service API

1062549 Member Posts: 1

I have been trying to make a Java Rest Program that can read JSON from the LinkedIn Rest Service API. The LinkedIn Rest Service API uses HTTPS. I have used Firefox to obtain the LinkedIn HTTPS Cert as a .pem file, and imported it into a file call .keystore. I use Jersey's Client API to call the service passing it that same .keystore file. Despite all this I am still getting the same HTTP 401 Unauthorized Exception. I have very little experience when dealing with keystores, truststores, and https call, I would appreciate any help. I have posted relevant the code below. Is there anything I need to change?, Is anyone familiar with the SslConfigurator class of JAX-RS 2.4? Or the LinkedIn Rest Service API. I have tested the LinkedIn Rest API on Postman with an active access token and had no issues.

<span> public static String getLinkedInData(String oauthAccessToken){ SslConfigurator sslConfig = SslConfigurator.newInstance() .trustStoreFile("./keystore.jks") .trustStorePassword("adminadmin") .trustStoreType("JKS") .securityProtocol("SSL"); SSLContext sslContext = sslConfig.createSSLContext(); Client client = ClientBuilder.newBuilder().sslContext(sslContext).build(); String data ="</span><a class="jive-link-external-small" href=",first-name,last-name,email-address,phone-numbers">,first-name,last-name,email-address,phone-numbers</a><span>," + "picture-url,public-profile-url,location:(name))") .queryParam("oauth2_access_token", oauthAccessToken) .request() .header("x-li-format", "json") .get(String.class); return data; } </span>
This discussion has been closed.