Python - LinkedIn API获取配置文件错误

时间:2017-04-06 13:39:50

标签: python-3.x rest oauth-2.0 linkedin-api

这是一个内部项目。我的最终目标是获得我的联系细节。谁和我在同一个城市。

我是使用LinkedIn API的新手。我使用了回答here中提到的代码来生成访问令牌。现在我使用下面的行来获取我的LinkedIn个人资料。

application.get_profile(access_token['oauth_token'])

但我收到了以下错误。

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    application.get_profile(access_token['oauth_token'])
  File "C:\Python34\lib\site-packages\python_linkedin-2.0-py3.4.egg\linkedin\linkedin.py", line 189, in get_profile
    response = self.make_request('GET', url, params=params, headers=headers)
  File "C:\Python34\lib\site-packages\python_linkedin-2.0-py3.4.egg\linkedin\linkedin.py", line 169, in make_request
    params.update({'oauth2_access_token': self.authentication.token.access_token})
AttributeError: 'str' object has no attribute 'token'

有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:1)

It is a bit late I guess. But for future reference, this error comes from the fact that you need to call explicitly the token element from the linkedin application.

For instance, to generate the application, you need to enter the following:

from linkedin_v2 import linkedin
application = linkedin.LinkedInApplication(token=access_token['oauth_token'])

From there, you can then call the different function from application (like "application.get_profile()").

BR

答案 1 :(得分:0)

我认为您不需要再次传递身份验证令以获取您的个人资料。我也在使用python lib。

application.get_profile()

应返回个人资料的基本信息。然后查看使用选择器指定所需的端点。