创建应用
- 1在 PostNimbo 中打开 Settings > Apps,填写名称、描述、图片和重定向地址,创建一个 OAuth 应用。
- 2复制 client id 和 client secret。把 secret 保存在你的服务器上;如果泄露,可在同一页面轮换。
授权码流程
带上你的 client id、重定向地址、state 值,以及 PKCE S256 challenge(建议所有应用使用,无法保密 secret 的应用必须使用),把成员引导到授权确认页面。
https://postnimbo.com/oauth/authorize ?client_id=<client id> &response_type=code &redirect_uri=<your redirect address> &state=<random value> &code_challenge=<base64url(sha256(verifier))> &code_challenge_method=S256 &scope=posts:read posts:schedule
成员批准后,PostNimbo 会带着 code 和 state 重定向到你的地址。先校验 state,然后在几分钟内用 code 换取令牌:
curl -X POST https://postnimbo.com/api/oauth/token \ -d grant_type=authorization_code \ -d code=<code> \ -d client_id=<client id> \ -d client_secret=<client secret> \ -d code_verifier=<verifier> \ -d redirect_uri=<your redirect address>
{
"access_token": "pos_…",
"token_type": "bearer",
"scope": "posts:read posts:schedule"
}在 REST API 的 Authorization 请求头中发送访问令牌。在成员撤销你的应用之前,它会一直有效;请加密存储。
权限范围
只请求你的应用实际用到的权限。授权确认页面会用以下文字逐项列出。如果一个都不请求,令牌将获得完全访问权限,因此请优先使用权限范围。
ideas:writeSave ideas to your Ideas board, and remove ideas you saved (Undo)media:writeAdd images to your media libraryposts:readSee your brands, channels, scheduled posts and the posts waiting for approvalposts:scheduleSchedule posts to your channels (when your workspace asks for approval, your approvers get them first)ai:useWrite drafts with PostNimbo AI, within your plan's AI featureslink-in-bio:writeAdd links to your link-in-bio pagesanalytics:readSee a summary of your analyticsinbox:readSee how many inbox conversations are unreadwebhooks:writeSend an event to an address you choose (like Zapier, Make or n8n) when a post is published, a flow captures a lead (with its email or phone number) or a flow is completed
令牌能做什么
- 它以批准授权的成员身份操作:只能访问该成员的品牌和渠道,以及工作区授予该成员的渠道级别。
- 当工作区要求审批时,它排期的帖子会像该成员自己的帖子一样等待审批人处理。
- 超出权限范围的路由返回 403。请成员重新登录以授予更多权限。
