Skip to content

Commit 19353c9

Browse files
bedfordseanadamgross42
authored andcommitted
Externalised verify TOKEN into Heroku config var (#16)
* Externalised verify TOKEN into Heroku config var * Remove console.log statements
1 parent 21594ec commit 19353c9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

heroku/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ This is a sample client for [Facebook's Graph API Webhooks](https://developers.f
1111

1212
### Facebook
1313
1. Create a new [Facebook application](https://developers.facebook.com/apps).
14-
1. Set up your Facebook application's [Graph API Webhooks subscription](https://developers.facebook.com/docs/graph-api/webhooks/#setup) using `https://<your-subdomain>.herokuapp.com/facebook` as the callback URL and `token` as the verify_token.
14+
1. Set up your Facebook application's [Graph API Webhooks subscription](https://developers.facebook.com/docs/graph-api/webhooks/#setup) using `https://<your-subdomain>.herokuapp.com/facebook` as the callback URL. It is recommended that you set a `TOKEN` [config var](https://devcenter.heroku.com/articles/config-vars) as part of the set up of your Heroku app to secure requests. If you choose not to set a config var, then you will need to set a verify token of 'token' when configuring the callback URL.
1515

1616
### Instagram
1717
1. Register an [Instagram API client](https://instagram.com/developer/clients/manage/).
18-
1. Set up your client's [subscription](https://www.instagram.com/developer/subscriptions/) using your `https://<your-subdomain>.herokuapp.com/instagram` as the callback URL and `token` as the verify_token.
18+
1. Set up your client's [subscription](https://www.instagram.com/developer/subscriptions/) using your `https://<your-subdomain>.herokuapp.com/instagram` as the callback URL. It is recommended that you set a `TOKEN` [config var](https://devcenter.heroku.com/articles/config-vars) as part of the set up of your Heroku app to secure requests. If you choose not to set a config var, then you will need to set a verify token of 'token' when configuring the callback URL.

heroku/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ app.listen(app.get('port'));
1717
app.use(xhub({ algorithm: 'sha1', secret: process.env.APP_SECRET }));
1818
app.use(bodyParser.json());
1919

20+
var token = process.env.TOKEN || 'token';
2021
var received_updates = [];
2122

2223
app.get('/', function(req, res) {
2324
console.log(req);
2425
res.send('<pre>' + JSON.stringify(received_updates, null, 2) + '</pre>');
2526
});
2627

27-
app.get(['/facebook', '/instagram'], function(req, res) {
28+
app.get(['/facebook', '/instagram'], function(req, res) {
2829
if (
2930
req.param('hub.mode') == 'subscribe' &&
30-
req.param('hub.verify_token') == 'token'
31+
req.param('hub.verify_token') == token
3132
) {
3233
res.send(req.param('hub.challenge'));
3334
} else {

0 commit comments

Comments
 (0)