Apache Oltu Linkedin Integration Example

I am looking forward to developing an example of Spring MVC + Apache Oltu + Linkedin integration. In this example, you need to send the client ID and secret key to access the private resource from the linked site.

The first step is that we need to create the application on Linkedin, follow these steps: http://codeboxr.com/how-to-create-linkedin-app.html

After creating the application, you need to make sure that you specify a value for the redirect URL.

In the java code that I used setScope ("r_network w_share r_basicprofile") SetState ("987654321")

When I used the following code:

request= new OAuthBearerClientRequest("https://api.linkedin.com/v1/people/").buildQueryMessage(); 

I get the following error message. Can anyone please?

 Could not access resource: 401 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <error> <status>401</status> <timestamp>1429554559432</timestamp> <request-id>QJWNLL5PWX</request-id> <error-code>0</error-code> <message>Unknown authentication scheme</message> </error> 

The important thing, I get the correct details below, but it seems to refer to private resources:

  {"access_token":"SQXZVmVM05AOzDB_DdBm5iaJkrEC8oK-FgE1m1snEZbMcKUODew9I0ZQ6NWc8JtGDxTtEd-yyPul0FtF3-hG4ah6LZ9P4oaSVuhhtybRFmjfsZcJwOs5Lm2IDUGQnjmq5EdT3PVR7Bocq31VBXg0JtkQdImab945oicO_w2j6CjlByp-bWw", "expires_in":5108376} FgE1m1snEZbMcKUODew9I0ZQ6NWc8JtGDxTtEd-yyPul0FtF3-hG4ah6LZ9P4oaSVuhhtybRFmjfsZcJwOs5Lm2IDUGQnjmq5EdT3PVR7Bocq31VBXg0JtkQdImab945oicO_w2j6CjlByp-bWw",  {"access_token":"SQXZVmVM05AOzDB_DdBm5iaJkrEC8oK-FgE1m1snEZbMcKUODew9I0ZQ6NWc8JtGDxTtEd-yyPul0FtF3-hG4ah6LZ9P4oaSVuhhtybRFmjfsZcJwOs5Lm2IDUGQnjmq5EdT3PVR7Bocq31VBXg0JtkQdImab945oicO_w2j6CjlByp-bWw", "expires_in":5108376} 
+4
spring-mvc spring-social-linkedin linkedin oltu
source share
1 answer

It seems that you are successfully getting the OAuth 2.0 access token, you need to pass the access_token to the request parameter when calling the API. How OAuth 2.0 authentication is handled (OAuth 1.0 required the access token to be in the header, while OAuth 2.0 relied on the request parameter).

For example:

GET https://api.linkedin.com/v1/people/~?oauth2_access_token= {your-token}

Please follow the link if, in case more detailed information is required: https://developer-programs.linkedin.com/forum/unknown-authentication-scheme

If you send a token along with a request for access to protected resources, you should receive the following data.

Corrected code snippet:

 request= new OAuthBearerClientRequest ("https://api.linkedin.com/v1/people/~?oauth2_access_token="+oAuthResponse.getAccessToken()). buildQueryMessage(); 

In my example, I get the following HTTP 200 OK response, I just want to show you.

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <person> <id>LLIyXMKhNI</id> <first-name>FirstName</first-name> <last-name>LastName</last-name> <headline>Spring Developer at Amazon</headline> <site-standard-profile-request> <url>https://www.linkedin.com/profile/view?id=154416688&amp;authType=name&amp;authToken=ipNL&amp;trk=api*a4360331*s4423501*</url> </site-standard-profile-request> </person> 

Hope this helps you.

+6
source share

All Articles