DEKHTIARJonathan / python3-linkedin

Python3 interface to the LinkedIn API
https://dekhtiarjonathan.github.io/python3-linkedin/
MIT License
84 stars 36 forks source link

Application methods error #3

Closed alceal closed 7 years ago

alceal commented 7 years ago

I'm testing the application methods according to the doc.

Works:

application.get_profile()
application.get_profile(selectors=['id', 'first-name', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations'])
application.search_company(selectors=[{'companies': ['name', 'universal-name', 'website-url']}], params={'keywords': 'apple microsoft'})
application.follow_company(1035)
application.unfollow_company(1035)
application.submit_share('Posting from the API using JSON', 'A title for your share', None, 'https://www.linkedin.com', 'https://d.pr/3OWS')

Works but unexpected result:

application.get_companies(company_ids=[1035], universal_names=['apple'], selectors=['name'], params={'is-company-admin': 'true'})

{'_total': 0}

Doesn't work:

application.get_connections()
application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'apple microsoft'})
application.search_job(selectors=[{'jobs': ['id', 'customer-job-code', 'posting-date']}], params={'title': 'python', 'count': 2})
application.get_group(41001)

title = 'Scala for the Impatient'
summary = 'A new book has been published'
submitted_url = 'https://horstmann.com/scala/'
submitted_image_url = 'https://horstmann.com/scala/images/cover.png'
description = 'It is a great book for the keen beginners. Check it out!'
application.submit_group_post(41001, title, summary, submitted_url, submitted_image_url, description)

from linkedin.linkedin import NETWORK_UPDATES
update_types = (NETWORK_UPDATES.CONNECTION, NETWORK_UPDATES.PICTURE)
application.get_network_updates(update_types)

from linkedin.models import LinkedInRecipient, LinkedInInvitation
recipient = LinkedInRecipient(None, 'john.doe@python.org', 'John', 'Doe')
invitation = LinkedInInvitation('Hello John', "What's up? Can I add you as a friend?", (recipient,), 'friend')
application.send_invitation(invitation)

The same error:

Traceback (most recent call last):
  File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/utils.py", line 49, in raise_for_error
    response.raise_for_status()
  File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.linkedin.com/v1/people/~/connections?oauth2_access_token=AQVNl-***************
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/linkedin.py", line 250, in get_connections
    raise_for_error(response)
  File "/Users/alceal/Dropbox/Projects/Python/.virtualenvs/linkedin-bot/lib/python3.6/site-packages/linkedin/utils.py", line 62, in raise_for_error
    raise ex(message)
linkedin.exceptions.LinkedInForbiddenError: 403 Client Error: Forbidden for url: https://api.linkedin.com/v1/people/~/connections?oauth2_access_token=AQVNl-**************: Access to connections denied
DEKHTIARJonathan commented 7 years ago

@alceal can you share a complete code here ? I think you can upload a file. Remove your API Keys, I'll put mine. Thanks

alceal commented 7 years ago

I think the answer is here:

https://developer.linkedin.com/support/developer-program-transition

DEKHTIARJonathan commented 7 years ago

I tried actually to fix it quickly but it does not seem I found the reason ... It seems to be an error an error produce by inconsistent results sent by the LinkedIn API...

Do you think of any other reason?