For server apps which should run in the background without any user interaction, Facebook's policy of expiring access tokens after 60 days is rather inconvenient. This app will generate long-lived tokens by mimicking user interactions in the browser (via PhantomJS) and save the tokens to your local file system.
If you mount your local volume /path/to/dir
into the container, the tokens will be stored at:
/path/to/dir/shortLivedAuthToken.txt
/path/to/dir/longLivedAuthToken.txt
$ docker run -e FB_CLIENT_ID=123 -e FB_CLIENT_SECRET=xzy \
-e [email protected] -e FB_USER_PASSWORD=secret \
-e FB_SCOPES=email,user_friends \
-v /path/to/dir:/token \
-it moertel/facebook-token-generator
FB_CLIENT_ID
: The client ID of your Facebook applicationFB_CLIENT_SECRET
: The client secret of your Facebook applicationFB_SCOPES
(optional): Comma-separated list of scopes to requestFB_USER_EMAIL
: Email address of Facebook user account for which to obtain an access tokenFB_USER_PASSWORD
: Password of Facebook user account
This script assumes that your Facebook language is English. If you use Facebook in another language, you may want to override the button texts:
FB_BUTTON_TEXT_GETTOKEN
(optional): Default is "Get Token"FB_BUTTON_TEXT_GETUSERACCESSTOKEN
(optional): Default is "Get User Access Token"FB_BUTTON_TEXT_GETACCESSTOKEN
(optional): Default is "Get Access Token"