Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gurpreetatwal/leadership-connections

Group project for Leadership
https://github.com/gurpreetatwal/leadership-connections

Last synced: 1 day ago
JSON representation

Group project for Leadership

Awesome Lists containing this project

README

        

# Leadership Connections

## Generating FB Token
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](https://developers.facebook.com/docs/pages/access-tokens). 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](https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension)

So finally the steps:

1. Go to [Facebook Graph Explorer](https://developers.facebook.com/tools/explorer/) and obtain a normal user access token.
- Make sure to change the appliction to "UGBA Connections"
- Required permissions: `publish_actions`, `publish_pages`, `manage_pages`, `pages_show_list`
2. Hop over to the terminal and run this command after setting the correct env vars
```bash
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")
```
3. Exchange the long lived user token for a page access token
```bash
export FB_TOKEN=$(http --body "https://graph.facebook.com/v2.11/ugba155connections?fields=access_token&access_token=$LONG_AT" | jq --raw-output ".access_token")
```
4. Store the page access token in `config/secret/development.json` for development or in the `FB_TOKEN` environment variable for production.