Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:29:41+00:00 2026-05-31T21:29:41+00:00

Using linkedin-j , I have the following code in one part of my application

  • 0

Using linkedin-j, I have the following code in one part of my application

LinkedInOAuthService service = LinkedInOAuthServiceFactory.getInstance()
        .createLinkedInOAuthService(consumerKey, consumerSecret);
LinkedInRequestToken requestToken = 
                    service.getOAuthRequestToken(linkedinCallbackURL);
String authUrl = requestToken.getAuthorizationUrl(); 

I redirect to the page pointed by authUrl and get to the correct LinkedIn page where I authorize my application. Then, the code which generates the page pointed by linkedinCallbackURL will execute this:

String verifier = request.getParameter("oauth_verifier");
LinkedInOAuthService oauthService = 
    LinkedInOAuthServiceFactory.getInstance()
                  .createLinkedInOAuthService(consumerKey, consumerSecret);  

LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken();  
LinkedInAccessToken accessToken = oauthService
            .getOAuthAccessToken(requestToken, verifier);

Unfortunately, I get this error:

com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Server returned HTTP response code: 401 for URL: https://api.linkedin.com/uas/oauth/accessToken

Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Server returned HTTP response code: 401 for URL: https://api.linkedin.com/uas/oauth/accessToken

What can be wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:29:42+00:00Added an answer on May 31, 2026 at 9:29 pm

    It turns out the problem is that I have to use the same LinkedInRequestToken object in both points. To do it, I saved it in the session in the first part:

    LinkedInRequestToken requestToken = 
                service.getOAuthRequestToken(linkedinCallbackURL);
    session.setAttribute("requestToken", requestToken); // <== THE BEEF
    String authUrl = requestToken.getAuthorizationUrl();
    

    Then I retrieved it from session:

    LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance()
            .createLinkedInOAuthService(consumerKey, consumerSecret);  
    // LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken();
    LinkedInRequestToken requestToken = 
            (LinkedInRequestToken) session.getAttribute("requestToken")  
    LinkedInAccessToken accessToken = oauthService
        .getOAuthAccessToken(requestToken, verifier);
    

    Note: Posting the question and the answer because I searched it A LOT and nobody found this specific problem. Doing it in the spirit of this question on Meta. Also, I did not answer some old questions because this error can happen for a myriad of reasons (it is like NullPointerException for LinkedIn API…) and the questions I have found did not have the same causes as far as I’ve seen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this week I'm having problems logging in LinkedIn using ruby mechanize. My code is
i am trying to make the post using my linkedin api application, The issue
I'm trying to access out-of-network profiles using the LinkedIn API, following the instructions from
I'm trying to connect to the linkedin API using the linkedin gem. I have
I am currently using the following code to try to pass the text in
I have an application using OmniAuth for authenticating with a variety of social networking
I have to integrate linkedIn sharing in my app, I will be using this
I have a Rails 3 application using Devise for authentication. In addition to the
I am using Twitter SDk and linkedin sdk for iOS in my Iphone application
I am using the LinkedIn iOS SDK using oAuth in my IPhone application. Its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.