Expand description
§gen-linkedin
Minimal LinkedIn API client for CI pipelines. Focuses on creating simple text posts for release announcements.
- Default feature:
posts(new REST Posts API) - Optional features:
ugc(legacy v2 UGC Posts),oauth2(helpers for interactive flows)
§Usage (CI)
Provide a bearer token via env var and create a post:
use gen_linkedin::{auth::EnvTokenProvider, client::Client};
#[cfg(feature = "posts")] use gen_linkedin::posts::{PostsClient, TextPost};
let token = EnvTokenProvider { var: "LINKEDIN_ACCESS_TOKEN".into() };
let li = Client::new(token)?;
let posts = PostsClient::new(li);
let post = TextPost::new("urn:li:person:...", "Hello LinkedIn!");
let _resp = posts.create_text_post(&post).await?;§Security
- Never log tokens; store in your CI secret manager.
- Uses rustls; no OpenSSL required. gen-linkedin: LinkedIn draft generation and post publishing for CI usage.
This crate provides two main capabilities:
-
Draft generation — scan Zola/Hugo blog posts for a
[linkedin]frontmatter section, build staged.linkedinJSON files, and stamp the source frontmatter with a creation date (idempotent). -
Post publishing — read staged
.linkedinfiles, publish each as a LinkedIn text post via the Posts API, write apublisheddate back into the source frontmatter, and delete the draft file.
§Frontmatter convention
A blog post opts in by adding a [linkedin] section to its TOML
frontmatter:
[linkedin]
description_file = "linkedin.md" # preferred for long posts
# description = "Short inline text is also accepted."The post text must be author-written and is not derived from any other
frontmatter field. LinkedIn posts are validated against
LINKEDIN_POST_MAX_CHARS (including the appended post link).
§Authentication
Callers supply a LinkedIn access token and author URN directly. Token
acquisition (OAuth 2.0) is outside the scope of this crate. See
auth::StaticTokenProvider for the simple bearer-token provider used
in CI contexts.
Re-exports§
pub use crate::draft::Draft;pub use crate::draft::DraftError;pub use crate::draft::LinkedinFile;pub use crate::draft::LINKEDIN_POST_MAX_CHARS;pub use crate::error::Error;pub use crate::frontmatter::FrontMatter;pub use crate::frontmatter::LinkedIn;pub use crate::post::Post;pub use crate::post::PostError;
Modules§
- auth
- Token providers for bearer tokens used to authenticate with LinkedIn.
- client
- Base HTTP client wrapper shared by feature modules.
- draft
- LinkedIn draft generation from blog post frontmatter. LinkedIn draft generation from blog post frontmatter.
- error
- Error types returned by this crate.
- frontmatter
- Serde-based frontmatter types for the
[linkedin]TOML section. Frontmatter types for LinkedIn-enabled blog posts. - post
- LinkedIn post publishing from staged draft files.
- posts
posts - LinkedIn Posts API (REST) support.