Group project for Leadership
MPL-2.0 License
To be able to post pictures to the facebook page, we need a page access token. A page access token can be generated by first getting a user access token with page post permissions and then exchanging that for a page access token as detailed here. This a problem with this flow in that the page access token expires in an hour and so does the user access token, so an admin would have to reauth the app on an hourly basis.
This can be solved by exchanging a "long-lived" user access token for a page access token. Long lived page access tokens have no expiration. ref
So finally the steps:
publish_actions
, publish_pages
, manage_pages
, pages_show_list
export LONG_AT=$(http --body "https://graph.facebook.com/v2.11/oauth/access_token?grant_type=fb_exchange_token&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&fb_exchange_token=$USER_AT" | jq --raw-output ".access_token")
export FB_TOKEN=$(http --body "https://graph.facebook.com/v2.11/ugba155connections?fields=access_token&access_token=$LONG_AT" | jq --raw-output ".access_token")
config/secret/development.json
for development or in the FB_TOKEN
environment variable for production.