diff --git a/l2pauth.py b/l2pauth.py
index 6713debb739cd6c6802ca8e136d55b49822f13f6..d658ee431b2273258571c0c4a4ec5e0c9e7782e8 100644
--- a/l2pauth.py
+++ b/l2pauth.py
@@ -16,6 +16,8 @@ def oauthget(endpoint, **args):
 
 @app.route('/l2pauth')
 def start_l2pauth():
+	if 'L2P_APIKEY' not in config:
+		return render_template("500.html"), 500
 	code = oauthget('code', scope='l2p2013.rwth')
 	session['oauthcode'] = code['device_code']
 	session['oauthscope'] = 'l2p'
@@ -23,6 +25,8 @@ def start_l2pauth():
 
 @app.route('/rwthauth')
 def start_rwthauth():
+	if 'L2P_APIKEY' not in config:
+		return render_template("500.html"), 500
 	code = oauthget('code', scope='userinfo.rwth')
 	session['oauthcode'] = code['device_code']
 	session['oauthscope'] = 'rwth'
@@ -30,6 +34,8 @@ def start_rwthauth():
 
 @app.before_request
 def finish_oauth():
+	if 'L2P_APIKEY' not in config:
+		return
 	if 'oauthcode' not in session or 'oauthscope' not in session:
 		return
 	token = oauthget('token', code=session['oauthcode'], grant_type='device')
diff --git a/server.py b/server.py
index df9955bb549e454ae52375d4f366859304fd36cb..4c101f54a7cb1e6ada6e75ed8dfaf1a90ac4f1e7 100644
--- a/server.py
+++ b/server.py
@@ -592,7 +592,6 @@ import importer
 import sorter
 if 'ICAL_URL' in config:
 	import meetings
-if 'L2P_APIKEY' in config:
-	import l2pauth
+import l2pauth
 import jobs
 import timetable