Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update LinkedIn connector to use v2 APIs#1460

Merged
srenatus merged 1 commit into
dexidp:masterfrom
tanmaykm:tan/linkedin
Jun 3, 2019
Merged

Update LinkedIn connector to use v2 APIs#1460
srenatus merged 1 commit into
dexidp:masterfrom
tanmaykm:tan/linkedin

Conversation

@tanmaykm
Copy link
Copy Markdown
Contributor

This updates LinkedIn connector to use the more recent v2 APIs. Necessary because v1 APIs are not able to retrieve email ids any more with the default permissions.

The API URLs are now different. Fetching the email address is now a separate call, made after fetching the profile details. The r_basicprofile permission is not needed any more, and r_liteprofile (which seems to be the one assigned by default) is sufficient.

The relevant API specifications are at:

fixes #1452

Copy link
Copy Markdown
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you! Some comments from my mobile, I'll elaborate later if need be.

Comment thread connector/linkedin/linkedin.go Outdated
Comment thread connector/linkedin/linkedin.go Outdated
@tanmaykm tanmaykm force-pushed the tan/linkedin branch 3 times, most recently from c995fe3 to 08966e8 Compare June 1, 2019 19:27
@tanmaykm
Copy link
Copy Markdown
Contributor Author

tanmaykm commented Jun 1, 2019

Thanks @srenatus for checking. I have added a commit to unmarshal into a nested struct. Hope that addresses both your comments?

Copy link
Copy Markdown
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tanmaykm would your bear with me for another quick round? I'd be happy to merge this without the return args fixed, but moving the email != "" check into the helper method -- if you agree -- would be nice. 😃

Comment thread connector/linkedin/linkedin.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer non-named return values, but that's mostly a matter of taste and not consistent even within this code base. So, let's leave it as is, since we're not using naked returns, there's little harm done. 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

Comment thread connector/linkedin/linkedin.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is this validation good enough? From glancing at the API docs (thanks for including the links, much appreciated!), handle~ could be missing because something (no idea what!) went wrong...?

With the current code, that would mean email remains "" (unassigned) and err would still be nil because of the way JSON unmarshaling works. (Its errors aren't for cases where expected fields aren't found, but rather more low-level stuff. If you try to unmarshal {this:"garba"ge}} for example.)

💡 looks like we'd catch that below, in this check -- I think I'd propose moving that into this helper method: "if primaryEmail returns a non-nil error, it has successfully retrieved the email address" sounds like a decent property for a function with that name. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agree. Will make that change in a bit.

@tanmaykm
Copy link
Copy Markdown
Contributor Author

tanmaykm commented Jun 3, 2019

Hi @srenatus, I have now made the change to check for email != "" inside the helper method.

@srenatus
Copy link
Copy Markdown
Contributor

srenatus commented Jun 3, 2019

@tanmaykm thank you! would you mind squashing the commits? 😃

This updates LinkedIn connector to use the more recent v2 APIs. Necessary because v1 APIs are not able to retrieve email ids any more with the default permissions.

The API URLs are now different. Fetching the email address is now a separate call, made after fetching the profile details. The `r_basicprofile` permission is not needed any more, and `r_liteprofile` (which seems to be the one assigned by default) is sufficient.

The relevant API specifications are at:
- https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api
- https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/primary-contact-api
- https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/migration-faq#how-do-i-retrieve-the-members-email-address
@tanmaykm
Copy link
Copy Markdown
Contributor Author

tanmaykm commented Jun 3, 2019

Yup, done!

@srenatus srenatus merged commit c19ada3 into dexidp:master Jun 3, 2019
mmrath pushed a commit to mmrath/dex that referenced this pull request Sep 2, 2019
Update LinkedIn connector to use v2 APIs

This updates LinkedIn connector to use the more recent v2 APIs. Necessary because v1 APIs are not able to retrieve email ids any more with the default permissions.

The API URLs are now different. Fetching the email address is now a separate call, made after fetching the profile details. The r_basicprofile permission is not needed any more, and r_liteprofile (which seems to be the one assigned by default) is sufficient.

The relevant API specifications are at:

    https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api
    https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/primary-contact-api
    https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/migration-faq#how-do-i-retrieve-the-members-email-address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkedIn connector fails with v1 APIs

2 participants