Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkedin: Migrate to versioned APIs #1058

Open
peternees opened this issue Apr 26, 2023 · 1 comment
Open

Linkedin: Migrate to versioned APIs #1058

peternees opened this issue Apr 26, 2023 · 1 comment

Comments

@peternees
Copy link

Linkedin changes to versioned api. See: https://learn.microsoft.com/en-us/linkedin/marketing/versioning?trk=eml-mktg-cust-202304-global-api-migrations-june&mcid=7054174543908663296&src=e-eml&view=li-lms-2023-04

This has some impact.

1.Change needed to OAuth20Service

final OAuth20Service service = new ServiceBuilder(clientId)
                .apiSecret(clientSecret)
                .defaultScope(new ScopeBuilder("r_liteprofile", "r_emailaddress"))
                .callback("http://example.com/callback")
                .build(LinkedInApi20.instance());

a. LinkedInApi20 need different endpoints: change v2 to rest

    public String getAccessTokenEndpoint() {
        return "https://www.linkedin.com/oauth/**rest**/accessToken";
    }

    protected String getAuthorizationBaseUrl() {
        return "https://www.linkedin.com/oauth/**rest**/authorization";
    }

This could be solved by using an extention of LinkedInApi20 with the rest endpoint. But it is better that LinkedInApi20 gets updated.

b. the oauth request need to get a version header. I think for this, scribejava lib needs a change

  1. Change to Resource api. This is easy and does not require a change of the scribeapi.

In the example https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/LinkedIn20Example.java change the resource endpoint:
now:
```
private static final String PROTECTED_RESOURCE_URL = "https://api.linkedin.com/v2/me";
private static final String PROTECTED_EMAIL_RESOURCE_URL
= "https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))";


chage to
private static final String PROTECTED_RESOURCE_URL = "https://api.linkedin.com/**rest**/me";
private static final String PROTECTED_EMAIL_RESOURCE_URL
        = "https://api.linkedin.com/**rest**/emailAddress?q=members&projection=(elements*(handle~))";
..
final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
**request.addHeader("LinkedIn-Version", "202304");**
@peternees
Copy link
Author

After testing, some additional info (I should have done that before creating the issue):

So it seems that, for the moment, only the profile api (/me) should change to https://api.linkedin.com/rest/me with version header.

So no need for a change in the lib, but for the linkedin example.

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

No branches or pull requests

1 participant