简体   繁体   中英

Python - LinkedIn API get profile error

This is for an internal project. My end goal is to get details of my connections. who are in same city as I am.

I am new in using LinkedIn API . I have used code mentioned in answer here to generate the access token. Now I am using below line to get my LinkedIn profile.

application.get_profile(access_token['oauth_token'])

But I am getting below error.

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'

Can someone please help me?

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

I don't think you need to pass the auth token again to get your profile. I am also using the python lib.

application.get_profile()

Should return the basic information for your profile. Then look into using selectors to specify what endpoints you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM