Apache Oltu Linkedin集成示例 [英] Apache Oltu Linkedin Integration example
问题描述
我期待开发 Spring MVC + Apache Oltu + Linkedin 集成示例.在此示例中,您需要发送客户端ID"和客户端密钥"以从链接到的站点"中访问私有资源.
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.
第一步-我们需要在Linkedin中创建App,请按照以下步骤操作: http ://codeboxr.com/how-to-create-linkedin-app.html
First Step - we need to create App in Linkedin, follow the steps: http://codeboxr.com/how-to-create-linkedin-app.html
创建应用后,您需要确保已为重定向URL设置了值.
Once App is created, you need to make sure you've given value for the redirect URL.
在我使用的Java代码中 setScope("r_network w_share r_basicprofile") setState("987654321")
In the java code I used setScope("r_network w_share r_basicprofile") setState("987654321")
当我使用以下代码时:
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}
推荐答案
似乎您已成功获取OAuth 2.0访问令牌,在进行API调用时需要在查询参数中传递access_token.这就是OAuth 2.0身份验证的处理方式(OAuth 1.0要求访问令牌位于标头中,而OAuth 2.0依赖于查询参数).
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).
例如:
获取 https://api.linkedin.com/v1/people/~? oauth2_access_token = {您的访问令牌}
GET https://api.linkedin.com/v1/people/~?oauth2_access_token={your-access-token}
如果需要更多详细信息,请点击链接: https://developer-programs.linkedin.com/forum/unknown-authentication-scheme
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.
更正后的代码段:
request= new OAuthBearerClientRequest
("https://api.linkedin.com/v1/people/~?oauth2_access_token="+oAuthResponse.getAccessToken()).
buildQueryMessage();
在我的示例中,我得到以下 HTTP 200 OK 响应,只是想向您展示..
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&authType=name&authToken=ipNL&trk=api*a4360331*s4423501*</url>
</site-standard-profile-request>
</person>
希望这会对您有所帮助.
Hope this will be help you.
这篇关于Apache Oltu Linkedin集成示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!