Apache Oltu Linkedin Integration example

ぃ、小莉子 提交于 2019-11-30 14:12:55

问题


I am looking forward to developed the Spring MVC + Apache Oltu + Linkedin integration example. In this example, you need to send Client ID and Client Secret to access the private resource from the Linked in Site.

First Step - we need to create App in Linkedin, follow the steps: http://codeboxr.com/how-to-create-linkedin-app.html

Once App is created, you need to make sure you've given value for the redirect URL.

In the java code 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 errror. Could 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>

An important thing, I am getting correct details below, but seems accessing private resources:

    {"access_token":"SQXZVmVM05AOzDB_DdBm5iaJkrEC8oK-FgE1m1snEZbMcKUODew9I0ZQ6NWc8JtGDxTtEd-yyPul0FtF3-hG4ah6LZ9P4oaSVuhhtybRFmjfsZcJwOs5Lm2IDUGQnjmq5EdT3PVR7Bocq31VBXg0JtkQdImab945oicO_w2j6CjlByp-bWw",
"expires_in":5108376}

回答1:


It seems that you're successfully obtaining an OAuth 2.0 access token, you'll need to pass access_token in a query parameter when making API calls. That's how OAuth 2.0 authentication is handled (OAuth 1.0 required the access token to be in the header whereas OAuth 2.0 relies on a query parameter).

For example:

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

Please follow the link, if in case requires more details: https://developer-programs.linkedin.com/forum/unknown-authentication-scheme

If you send token along with the request to access protected resources, then you should be getting the following details.

The corrected code snippet:

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

In My Example, I am getting the following HTTP 200 OK response, just wanted 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 will be help you.



来源:https://stackoverflow.com/questions/29755678/apache-oltu-linkedin-integration-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!