调用LinkedIn Get Posts API遇403权限问题,该接口是否仅向合作伙伴开放?
问题:LinkedIn通过Post URN获取帖子接口返回403权限错误
调用LinkedIn获取帖子的接口时遇到403 Forbidden错误,调用函数如下:
async function getPost(accessToken, postUrn) { const url = `https://api.linkedin.com/rest/posts/${encodeURIComponent( postUrn )}?viewContext=AUTHOR`; const response = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}`, "Content-Type": "application/x-www-form-urlencoded", "X-Restli-Protocol-Version": "2.0.0", "LinkedIn-Version": "202209", }, }); if (response.status == 200) { return await response.json(); } else { console.log(response.status); console.log(response.statusText); console.log(await response.json()); throw new Error(JSON.stringify(response)); } }
收到的响应:
403 Forbidden { serviceErrorCode: 100, code: 'ACCESS_DENIED', message: 'Not enough permissions to access: partnerApiPosts.GET.20220901' }
已在LinkedIn开发者页面为应用启用所有可用产品(Share on LinkedIn、Sign in with LinkedIn和Marketing Developer Platform),但微软文档未说明该接口仅对合作伙伴开放,想确认该接口是否仅对LinkedIn合作伙伴开放,以及错误原因。
解答
- 这个403错误的核心原因是:你调用的
partnerApiPosts.GET.20220901接口属于LinkedIn专属合作伙伴接口,普通开发者即便启用所有公开可用的开发者产品也无法访问。 - 你当前启用的Share on LinkedIn、Sign in with LinkedIn、Marketing Developer Platform都是面向普通开发者的公开产品,无法覆盖这类合作伙伴专属接口的权限。
- 若需获取帖子内容,可改用Marketing Developer Platform下的公开
/posts查询接口,但需满足以下条件:- 授权accessToken时申请了对应的权限范围(如获取成员个人帖子需
r_member_social,获取企业主页帖子需r_organization_social); - 这些权限需要经过LinkedIn的审核才能生效;
- 你要获取的帖子处于公开可见状态,或你有权限访问该主体的内容。
- 授权accessToken时申请了对应的权限范围(如获取成员个人帖子需
内容的提问来源于stack exchange,提问作者Gervasius Twinklewinkleson
相关产品推荐
相关产品推荐

