使用oauth2_access_token获取linkedIn中的连接 [英] Using oauth2_access_token to get connections in linkedIn
问题描述
我正在尝试使用其API获取 linkedIn中的连接,但是当我尝试检索连接时,出现了401未经授权的错误.
I'm trying to get the connections in linkedIn using their API, but when I try to retrieve the connections I get a 401 unauthorized error.
在官方文档中说
您必须使用访问令牌代表代表进行已认证的呼叫 用户的
进行API调用,您现在可以使用此access_token来代表该用户通过附加以下内容来进行API调用 您在API调用结束时输入"oauth2_access_token = access_token" 希望做出.
Make the API calls You can now use this access_token to make API calls on behalf of this user by appending "oauth2_access_token=access_token" at the end of the API call that you wish to make.
我要执行的API调用如下
The API call that I'm trying to do is the following
错误-> http://api.linkedin.com/v1/people/~/connections:(id,headline,first-name,last-name)?format = json& oauth2_access_token = access_token >
我尝试使用以下端点进行此操作,而没有任何问题.
I have tried to do it with the following endpoint without any problems.
确定-> ://api.linkedin.com/v1/people/~ :( id,名字,姓氏,格式名称,生日,行业,电子邮件地址,位置,标题,图片网址::(原始))?format = json& oauth2_access_token = access_token
此处描述了连接API的端点列表 http://developer.linkedin.com/documents/connections-api 我只是从那里复制并粘贴了一个端点,所以问题是获取连接的端点有什么问题?我想念什么?
this list of endpoints for the connections API are described here http://developer.linkedin.com/documents/connections-api I just copied and pasted one endpoint from there, so the question is what's the problem with the endpoint for getting the connections? what am I missing?
我正在使用的preAuth网址
for the preAuth Url I'm using
> https://www.linkedin.com/uas/oauth2/authorization?response_type = code& client_id = ConsumerKey & scope = r_fullprofile%20r_emailaddress%20r_network& state & state = NewGuid strong>& redirect_uri = 已编码的网址
https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=ConsumerKey&scope=r_fullprofile%20r_emailaddress%20r_network&state&state=NewGuid&redirect_uri=Encoded_Url
> https://www.linkedin.com/uas/oauth2/accessToken?grant_type = authorization_code& code = QueryString_Code & redirect_uri = EncodedCallback & client_id = ConsummerKey & client_secret = 消费者秘密
https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=QueryString_Code&redirect_uri=EncodedCallback&client_id=ConsummerKey&client_secret=ConsumerSecret
请在附件中找到请求权限的登录屏幕
please find attached the login screen requesting the permissions
切换到https并像魅力一样工作!
Switched to https and worked like a charm!
推荐答案
为特定的scope
颁发了访问令牌,该令牌描述了您所请求的权限的程度.当启动身份验证事务时,您将添加一个特定的参数(称为 scope ),该参数请求用户同意访问您想要的内容(在这种情况下为他们的连接).如果我没记错的话,在LinkedIn中是r_network
.
Access tokens are issued for a specific scope
that describes the extent of the permission you are requesting. When you start the authentication transaction, you add a specific parameter (called scope) that requests the user to consent access to what you want (in this case their connections). If I remember correctly, in LinkedIn that is r_network
.
在此处查看其文档: http://developer.linkedin.com/documents/authentication#granting
因此,您的通话完全可以,但是您的 access_token 可能没有足够的权限.
So, your call is perfectly ok, but very likely your access_token doesn't have enough privileges.
这篇关于使用oauth2_access_token获取linkedIn中的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!