Skip to content

Get Facebook Page posting credentials

Let keryx auth facebook capture a Page access token so keryx publish can post a text-and-image announcement to a Facebook Page (spec 0060 D10). It is the same Meta app as Instagram, but a different login: Instagram posting uses Instagram Login; Page posting needs Facebook Login for Business and a token for the Page itself. Ten minutes on top of the Instagram setup.

What you need

  • The Meta app from the Instagram how-to, with its app id (platforms.instagram.app_id, which auth facebook reuses unless platforms.facebook.app_id is set) and secret (FACEBOOK_APP_SECRET, or INSTAGRAM_APP_SECRET).
  • A Facebook Page you admin (for phpboyscout: https://www.facebook.com/phpboyscout).

1. Add Facebook Login for Business to the app

  1. In the app dashboard, Add product → Facebook Login for Business.
  2. Under its Settings, add the loopback redirects keryx uses, the same six as Instagram: https://localhost:3764/https://localhost:3769/.
  3. Under App Review → Permissions and features, make sure these are available: pages_show_list, pages_read_engagement, pages_manage_posts, pages_manage_engagement. For a Page you admin they work under Standard Access; no review is needed for your own Page.

2. Sign keryx in

keryx auth facebook

It opens the consent dialog (or prints the URL on a headless host), captures the code on the https loopback, swaps it for a user token, that for a long-lived one, then reads the Pages you can post to. One Page is taken as is; several are offered as a numbered list, and platforms.facebook.page_id in config pre-selects one. The Page's own token is stored (keychain, else the accounts file); platforms.facebook.{page_id,page_name,enabled,redirect_uri} are written to config.

In CI, FACEBOOK_PAGE_TOKEN in the environment is the token.

3. What a post looks like there

  • With an image: a photo post on the Page. The bytes are uploaded (no public URL needed, unlike Instagram), with the copy and hashtags as the caption, the link appended to it, and the alt text.
  • Without an image: a feed post with the copy and the link, which Facebook renders as a link card.
  • No video: a reel is not sent to Facebook.

Refresh

A long-lived Page token has no expiry. keryx auth refresh reads the Page with it and asks for re-auth if Meta rejects it (a changed password, a removed Page role, or a revoked app).