-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
[WIP] LinkedIn endpoint and syndicator #752
base: main
Are you sure you want to change the base?
Conversation
4a80a05
to
bb2c548
Compare
At the moment this syndicator works, but relies on an access token created using the LinkedIn OAuth Token Generator Tool (the token has an expiration of 60 days). Indiekit
|
bb2c548
to
cc273c3
Compare
I created a new package
The authorization flow starts when the user visits this page (I'm not very familiar with the codebase, so I just created a super simple view with nunjucks). To quickly reach that page, I added a link in the welcome page. When the user wants to allow Indiekit—or more precisely, the LinkedIn OAuth app they created for their Indiekit installation—they visit the authorization page on Indiekit, that redirects them to the LinkedIn consent screen. Note: the user first needs to create a LinkedIn OAuth app with the required OAuth scopes and the required callback URL. Tip If the LinkedIn OAuth app is created with the scope |
cc273c3
to
f51cfd7
Compare
f51cfd7
to
c5e9db9
Compare
Ooooh, I’ve longed thought about having UI-based OAuth for adding syndicators – this is so cool! I think I’d be tempted to have this encapsulated in one plugin (plugins can provide endpoints as well a syndication methods, if needed). I’d also be curious to know what, if anything, could be provided by Indiekit’s core (or a first-party plugin) to support building OAuth flows in the UI/application, so that this functionality could be added to other syndicators/content stores etc. |
Yes, I think it makes sense to keep the endpoints for the OAuth flow and the syndication logic in the same plugin. I just didn't know how to organize the code in Indiekit.
Absolutely. Most OAuth logic should be reusable across syndicators. I think most social networks (LinkedIn, Twitter, Reddit, etc) allow posting on the user's behalf using a OAuth 2.0 Authorization Code Flow (3-legged OAuth). I used the simple-oauth2 library to avoid implementing the entire OAuth 2.0 flow from scratch. I thought about putting the link to start the OAuth flow in the syndicator detail page: the user visits that page, gets redirected to the OAuth consent screen, clicks allow, returns the syndicator detail page. The user flow would be the same for other syndicators that require an OAuth flow. |
f94062a
to
1996a3d
Compare
57a0028
to
c2c31ed
Compare
09cfd93
to
25a68aa
Compare
1b91b6e
to
69936a4
Compare
This PR addresses issue #531
Warning
This PR is still a work in progress.
LinkedIn APIs, LinkedIn OAuth app, LinkedIn page
LinkedIn has several APIs (they call them API products).
In order to use any LinkedIn API we must create a LinkedIn OAuth app.
We also must associate a LinkedIn OAuth app with a LinkedIn page. However, we don't have to create a LinkedIn page ourselves, and we can use the Default Company Page (for API testing) instead.
Creating posts on LinkedIn
In order to create posts on LinkedIn we need to call the
CREATE
method of the LinkedIn Posts API. TheCREATE
method, like most other methods of this LinkedIn API, requires the OAuth 2.0 Authorization Code Flow (also called 3-legged OAuth). In order to create a LinkedIn post, the access token sent with the request needs to have thew_member_social
scope.The Posts API allows each LinkedIn OAuth app to create, each day, up to 500 posts per user, and up to 150,000 posts in total.
How to obtain an access token?
In production the user needs to go through the OAuth 2.0 flow. See example with simple-oauth2.
In development we can generate a LinkedIn access token using the OAuth Token Generator tool.
If you get this error in Chrome...
...try generating the token in Incognito mode as suggested here.
All access tokens issued by LinkedIn have an expiration of 60 days.
Useful links