跳到正文
开发者

OAuth 应用

让其他 PostNimbo 用户连接你的产品。他们登录后查看你请求的权限并批准,之后可随时在 Settings > Apps 中撤销。

创建应用

  1. 1在 PostNimbo 中打开 Settings > Apps,填写名称、描述、图片和重定向地址,创建一个 OAuth 应用。
  2. 2复制 client id 和 client secret。把 secret 保存在你的服务器上;如果泄露,可在同一页面轮换。

授权码流程

带上你的 client id、重定向地址、state 值,以及 PKCE S256 challenge(建议所有应用使用,无法保密 secret 的应用必须使用),把成员引导到授权确认页面。

1. 打开授权页面
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 换取令牌:

2. 换取 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>
3. 返回结果
{
  "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 library
  • posts:readSee your brands, channels, scheduled posts and the posts waiting for approval
  • posts: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 features
  • link-in-bio:writeAdd links to your link-in-bio pages
  • analytics:readSee a summary of your analytics
  • inbox:readSee how many inbox conversations are unread
  • webhooks: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。请成员重新登录以授予更多权限。

正在用 PostNimbo 构建产品?

告诉我们你在做什么。我们会协助你使用 API,审核应用以收录到目录,并添加集成所需的端点。