Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic renew facebook token #36

Merged
merged 2 commits into from
Nov 13, 2022
Merged

Automatic renew facebook token #36

merged 2 commits into from
Nov 13, 2022

Conversation

MartinDelille
Copy link
Member

@MartinDelille MartinDelille commented Apr 10, 2022

The facebook token expires after two months. Since it is possible to get a new token with the facebook API and update it in the github action secret, this would be nice to update it automatically (every two months) to reduce manual maintenance on the website.

If we forget to update the token, the event page will display en empty list: https://www.atelier-medias.org/les-evenements

@MartinDelille
Copy link
Member Author

I'm stuck and post a question here: https://stackoverflow.com/questions/72424607/update-a-github-repository-secret-from-a-github-action

@alex-rowbottom Do you have knowledge in facebook auth or github actions that could help ?

@MartinDelille
Copy link
Member Author

This could help: hmanzur/actions-set-secret#15

@MartinDelille
Copy link
Member Author

Here is the API call to get a token with a 45 days duration:

curl -i -X GET https://graph.facebook.com/$api_version/oauth/access_token?grant_type=fb_exchange_token&client_id=$app_id&client_secret={$app_secret}&fb_exchange_token=$facebook_token

The idea would be:

  1. Get a new token with the current one using the koala gem that make facebook API call easy (see event.rb
  2. Update the github action secret (see renew.rb)

@MartinDelille
Copy link
Member Author

Here is some help to update a repository secret: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret

@MartinDelille
Copy link
Member Author

@alex-rowbottom would you help me with that ?

@MartinDelille
Copy link
Member Author

I finally sorted this out because I struggled to renew the token every month. I first used my personal github token which was not very so I replaced it by a fine grained access token that can only read and write secret.

I'm still wondering if this is very safe because an external pull request could leak the secrets so I'd like some feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant