Commit 8cc08c6c authored by Roman Karwacik's avatar Roman Karwacik
Browse files

Merge branch 'debug-moodle-auth-no-error' into 'master'

Moodlesync debug

See merge request !33
parents e7bd0ba7 f42bf61d
from server import *
import requests
from mail import notify_admins
L2P_BASE = 'https://www3.elearning.rwth-aachen.de/_vti_bin/l2pservices/api.svc/v1/'
OAUTH_BASE = 'https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/'
......@@ -66,7 +67,12 @@ def finish_oauth():
session['l2p_courses'].append(course['uniqueid'])
elif session['oauthscope'] == 'moodle':
session['moodle_courses'] = []
for course in moodleget('getmyenrolledcourses', token['access_token'])['Data']:
session['moodle_courses'].append(str(course['id']))
data = moodleget('getmyenrolledcourses', token['access_token'])
if data and data.get('Data'):
for course in data['Data']:
session['moodle_courses'].append(str(course['id']))
else:
notify_admins('endpoint_exception', traceback=f"finish_oauth failed while getting moodle courses, data={str(data)}")
raise
del session['oauthscope']
oauthget('token', refresh_token=token['refresh_token'], grant_type='invalidate')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment