Skip to content
Snippets Groups Projects

Moodlesync debug

Merged Roman Karwacik requested to merge romank/website:debug-moodle-auth-no-error into master
1 file
+ 8
2
Compare changes
  • Side-by-side
  • Inline
+ 8
2
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')
Loading