I want to include some OpenEdx lesson on my web application. For this, I decided to use the LTI protocol which is supported by OpenEDX (as consumer and provider in last release).
My application, as LTI consumer, already integrate with success some contents from moodle LTI provider system.
When I try to use the same code, everything works until i send via post all the parameter, openEDX respond me error 400 to my post request.
To make my test, I'm using the fullstack installation (Dogwood version) which i modify a bit to enable LTI provider functionnality according to : http://edx.readthedocs.org/projects/edx-installing-configuring-and-running/en/latest/configuration/lti/enable_lti.html
Then I follow documentation to configure LTI provider in administration interface, and an other page from official documentation to build my LTI call URL, which looks like : http://192.168.33.10/lti_provider/courses/course-v1:edX+DemoX+Demo_Course/block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_0270f6de40fc
In my post request I send these parameters:
- user_id
- lis_person_name_given
- lis_person_name_family
- lis_person_name_full
- lis_person_contact_email_primary
- resource_link_id
- tool_consumer_instance_guid
- endpoint_url
- oauth_version
- oauth_consumer_key
- oauth_signature
- oauth_signature_method
- oauth_timestamp
- oauth_nonce
I already verify, all these parameter are properly send.
DO you have any idea where the error can come from?
Thanks a lot!
[EDIT :] I finally found where the trouble is. I miss some parameter which are only recommended in LTI bu mandatory in OpenEDX case. If it miss a mandorty parameter, open edx return an error 400.
On /lms/djangoapps/lti_provider/views.py:
REQUIRED_PARAMETERS = [
'roles', 'context_id', 'oauth_version', 'oauth_consumer_key',
'oauth_signature', 'oauth_signature_method', 'oauth_timestamp',
'oauth_nonce', 'user_id'
]
""" code which return error 400
params = get_required_parameters(request.POST)
if not params:
return HttpResponseBadRequest()
def get_required_parameters(dictionary, additional_params=None):
"""
Extract all required LTI parameters from a dictionary and verify that none
are missing.
:param dictionary: The dictionary that should contain all required parameters
:param additional_params: Any expected parameters, beyond those required for
the LTI launch.
:return: A new dictionary containing all the required parameters from the
original dictionary and additional parameters, or None if any expected
parameters are missing.
"""
params = {}
additional_params = additional_params or []
for key in REQUIRED_PARAMETERS + additional_params:
if key not in dictionary:
return None
params[key] = dictionary[key]
return params