使用 oauth2_access_token 在linkedIn 中获取连接 [英] Using oauth2_access_token to get connections in linkedIn

查看:22
本文介绍了使用 oauth2_access_token 在linkedIn 中获取连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用他们的 API 获取 linkedIn 中的连接,但是当我尝试检索连接时,我收到了 401 未经授权的错误.

在官方文档中说

<块引用>

您必须使用访问令牌来代表进行

所以,您的通话完全没问题,但很可能您的 access_token 没有足够的权限.

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.

in the official documentation says

You must use an access token to make an authenticated call on behalf of a user

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.

The API call that I'm trying to do is the following

Error --> 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.

OK --> https://api.linkedin.com/v1/people/~:(id,first-name,last-name,formatted-name,date-of-birth,industry,email-address,location,headline,picture-urls::(original))?format=json&oauth2_access_token=access_token

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?

EDIT: 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&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=ConsumerSecret

please find attached the login screen requesting the permissions

EDIT2: Switched to https and worked like a charm!

解决方案

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.

Check their documentation here: http://developer.linkedin.com/documents/authentication#granting

So, your call is perfectly ok, but very likely your access_token doesn't have enough privileges.

这篇关于使用 oauth2_access_token 在linkedIn 中获取连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆