Updated examples get_profile and create_posts in line with new API#60
Updated examples get_profile and create_posts in line with new API#60clockworkpc wants to merge 1 commit intolinkedin-developers:mainfrom
get_profile and create_posts in line with new API#60Conversation
|
I also wrote a tidier script that focuses on the new API: |
ZLeventer
left a comment
There was a problem hiding this comment.
The /me → /userinfo migration in the examples is correct and needed. A few specific notes:
-
entity['id']→entity['sub']— Right. The/userinfoendpoint returns an OpenID Connect claims set where the user identifier issub, notid. This is per the OIDC spec (RFC 7519). -
Variable renaming (
response→response_basic,response_field_projects,response_display_image) — Good change for the examples. Reusingresponseacross sequential calls is fine in scripts but confusing in documentation that people read linearly. -
Field projections update — The new fields (
sub,email_verified,name,locale,given_name,family_name,email,picture) match the standard OpenID Connect claims. The old fields (id,firstName:(localized),lastName) were LinkedIn-specific and no longer available on the new endpoint.
I addressed the same /me deprecation in the examples in PR #73 — our changes overlap. Happy to coordinate if the maintainers want to merge one over the other.
The current examples use the
/meendpoint and try to identify the profile by the following URN string:f"urn:li:person:{me_response.entity['id']}.However, I found that even though I have a valid 3-legged-token with the necessary scopes enabled, I was getting an error.
I believe that the most recent changes to the LinkedIn API require the following changes:
/userinfoGET endpoint instead of/meme_response.entity['sub']instead ofme_response.entity['id']There are some further differences in the names of the fields returned by the
userinfoandmeendpoints, which are reflected in the proposed changes in the exampleget_profile.py.