Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access LinkedIn REST API without front-end (e.g. OAuth2 redirect)

Goal

Fetch a company's updates save them locally in a background task

Problem

This should be done as a backend service without any real user interaction. We could provide a user account to use, but the authentication is a problem: There is literally no one to answer the OAuth redirect and there is no public redirect URL to configure, since it's a background service.

Is there any way to access the API without having a redirect URL or a real user?

like image 362
Sebastian Wramba Avatar asked Jan 22 '15 12:01

Sebastian Wramba


People also ask

Are you already using LinkedIn's new OAuth UI?

If your application has implemented LinkedIn's OAuth 2.0 UI within the past year, it is likely you are already using the new OAuth 2.0 UI and no further action is required. What's new?

How to connect with LinkedIn REST API?

Connecting with LinkedIn Rest API is easy once you know how to authorize the user. Following are the steps that can be performed in .NET / Java using HttpClients or simply from JQuery / Javascript. You need to set the scope of your application after registering, by scope means to define which LinkedIn feature your application is going to use.

When will automatic redirects start for OAuth users?

Starting July 23, 2018, we will begin performing automatic redirects for developer applications currently using our legacy OAuth 2.0 UI in favor of our new OAuth 2.0 UI. This change will take effect gradually for select members only, with all members fully upgraded by August 6, 2018.

What permissions are available for accessing the LinkedIn API?

The LinkedIn API uses OAuth 2.0 for user authorization and API authentication. Applications must be authorized and authenticated before they can fetch data from LinkedIn or get access to member data. This page summarizes the available permissions and partner programs available for accessing LinkedIn APIs.


1 Answers

You can get an initial access token in a regular front end flow, for you as the app developer i.e yourself as the LinkedIn user. Once you've got that, you can store it in the backend and use it for 60 days to get access to the LinkedIn APIs.

After 60 days you need to refresh the token as documented in: https://developer.linkedin.com/documents/handling-errors-invalid-tokens

Unfortunately LinkedIn does not (yet) support an autonomous refresh flow where your app can get a new access token by presenting a refresh token on a backchannel. So the developer will have to refresh the access token by a manual login every 2 months.

like image 157
Hans Z. Avatar answered Sep 23 '22 13:09

Hans Z.