gpt4 book ai didi

spring-mvc - Apache Oltu Linkedin 集成示例

转载 作者:行者123 更新时间:2023-12-03 12:20:30 26 4
gpt4 key购买 nike

我期待开发 Spring MVC + Apache Oltu + Linkedin 集成示例。在此示例中,您需要发送 Client ID 和 Client Secret 以从 Linked in Site 访问私有(private)资源。

第一步 - 我们需要在 Linkedin 中创建 App,请按照以下步骤操作:http://codeboxr.com/how-to-create-linkedin-app.html

创建应用程序后,您需要确保已为重定向 URL 提供了值。

在我使用的java代码中
setScope("r_network w_share r_basicprofile")
setState("987654321")

当我使用以下代码时:

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

我收到以下错误。有人可以请吗?
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>

重要的是,我在下面得到了正确的详细信息,但似乎访问了私有(private)资源:
    {"access_token":"SQXZVmVM05AOzDB_DdBm5iaJkrEC8oK-FgE1m1snEZbMcKUODew9I0ZQ6NWc8JtGDxTtEd-yyPul0FtF3-hG4ah6LZ9P4oaSVuhhtybRFmjfsZcJwOs5Lm2IDUGQnjmq5EdT3PVR7Bocq31VBXg0JtkQdImab945oicO_w2j6CjlByp-bWw",
"expires_in":5108376}

最佳答案

您似乎已成功获得 OAuth 2.0 访问 token ,在进行 API 调用时,您需要在查询参数中传递 access_token。这就是 OAuth 2.0 身份验证的处理方式(OAuth 1.0 要求访问 token 位于 header 中,而 OAuth 2.0 依赖于查询参数)。

例如:

获取 https://api.linkedin.com/v1/people/~?oauth2_access_token= {您的访问 token }

如果需要更多详细信息,请点击链接:https://developer-programs.linkedin.com/forum/unknown-authentication-scheme

如果您将 token 与访问 protected 资源的请求一起发送,那么您应该会获得以下详细信息。

更正后的代码片段:

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

在我的示例中,我得到以下 HTTP 200 正常 回应,只是想告诉你..
<?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>

希望这会对您有所帮助。

关于spring-mvc - Apache Oltu Linkedin 集成示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29755678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com