]> git.aero2k.de Git - sirius.git/commitdiff
Allow setting twitter consumer secret and key through the environment.
authorTom Hunger <tehunger@gmail.com>
Sun, 1 Mar 2015 17:04:41 +0000 (17:04 +0000)
committerTom Hunger <tehunger@gmail.com>
Sun, 1 Mar 2015 17:04:41 +0000 (17:04 +0000)
This is done in a backwards-compatible way using the hard-coded key
for now so I can add a better error message when the env vars are missing.

README.md
sirius/web/twitter.py

index 62fe42c8d60d5247d5c141ca2986bd4717b67673..6e2461f70fefd22f68f0fff7f7c4066161709ee2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,6 +11,24 @@ $ bin/gunicorn -k flask_sockets.worker sirius.server:app -b 0.0.0.0:5002 -w 1
 Navigate browser to http://127.0.0.1:5002/
 
 
+## Environment variables
+
+The server can be configured with the following variables:
+
+```
+TWITTER_CONSUMER_KEY=...
+TWITTER_CONSUMER_SECRET=...
+FLASK_CONFIG=...
+```
+
+For dokku this means using e.g.:
+
+```
+dokku config:set sirius FLASK_CONFIG=heroku
+dokku config:set sirius TWITTER_CONSUMER_KEY=DdrpQ1uqKuQouwbCsC6OMA4oF
+dokku config:set sirius TWITTER_CONSUMER_SECRET=S8XGuhptJ8QIJVmSuIk7k8wv3ULUfMiCh9x1b19PmKSsBh1VDM
+```
+
 ## Creating fake printers and friends
 
 Resetting the actual hardware all the time gets a bit tiresome so
index af0eacd2702110b71e79e142cc67e1e92798ca23..379dac30835ef28202cacbb89471b7ef4734b705 100644 (file)
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 
+import os
 import datetime
 import flask
 from gevent import pool
@@ -23,8 +24,8 @@ twitter = oauth_app.remote_app(
     request_token_url='https://api.twitter.com/oauth/request_token',
     access_token_url='https://api.twitter.com/oauth/access_token',
     authorize_url='https://api.twitter.com/oauth/authenticate',
-    consumer_key='DdrpQ1uqKuQouwbCsC6OMA4oF',
-    consumer_secret='S8XGuhptJ8QIJVmSuIk7k8wv3ULUfMiCh9x1b19PmKSsBh1VDM',
+    consumer_key=os.environ.get('TWITTER_CONSUMER_KEY', 'DdrpQ1uqKuQouwbCsC6OMA4oF'),
+    consumer_secret=os.environ.get('TWITTER_CONSUMER_SECRET', 'S8XGuhptJ8QIJVmSuIk7k8wv3ULUfMiCh9x1b19PmKSsBh1VDM'),
 )