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 e1613b1ff3954ee996d19ec783c67c8983439dda..3945c3a7d51d275705b3fb19f4c6c9f330bdda20 100644
--- a/server.py
+++ b/server.py
@@ -572,7 +572,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