Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

by Youness Madhoun -
Number of replies: 4

I am currently developing a flashcard application using python-django on the server side where I can launch it from moodle as an external tools 'Tool Provider (TP) of Learning Tools Interoperability (LTI) version 1.1', I want to pass grades and custom values ​​from TP back to Moodle LMS version 3.9.

When I launch my application from moodle, here is the information relating to the request received in the server side:

{'oauth_version': '1.0', 'oauth_nonce': '507d631132d9774f5ec94728de8c6faa', 'oauth_timestamp': '1624013991', 'oauth_consumer_key': 'djangoConsultKey','ced ',' data_idres:'ced '2', 'lis_idres:' : {"instanceid": "7", "userid": "2", "typeid": "6", "launchid": 323115609}, "hash": "cacf667303577a6731a59211f6b2c1c1e85f449646f3d74c4ce91b9b25cfdf9a "} ',' lis_outcome_service_url ':' http: //localhost/mod/lti/service.php ',

for testing reasons, i used postman to be able to send a post request with this information above but apparently i get an authentication or token error.

Knowing that lis_result_sourcedid and lis_outcome_service_url should be used, but I don't know how to make use of these parameters in the TP programs.

Attachment Sans titre (1).png
Attachment Sans titre.png
Average of ratings: -
In reply to Youness Madhoun

Re: Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Youness,

First up, I'd like to point out that LTI 1.1 is deprecated. LTI 1.3 is the current standard that new tools should aim to support. I'm only mentioning this in case you weren't aware. It would be a shame to spend a lot of time implementing 1.1 only to find this out later.

Now, It sounds like you're having problems with the grade sync. You can do this one of several ways:
1. Using Basic Outcomes (BO) 1.0. This is the old method and uses those 2 vars you mentioned - lis_result_sourcedid and lis_outcome_service_url. http://www.imsglobal.org/specs/ltiomv1p0/specification#toc-3. This is really only used for 1.1 tools. You can check out Moodle's own enrol/lti/ code to see how it generates the payload (https://github.com/moodle/moodle/blob/1fc5c588a4742f6b05ef526100f45708084e1815/enrol/lti/classes/helper.php#L357)
2. Using Assignment and Grade Services (AGS) 2.0. https://www.imsglobal.org/spec/lti-ags/v2p0. This method only needs the user id and the grade and is much simpler. You'd normally use this method for 1.3 tools. I will note that the issue which landed this originally (MDL-60416) did test this on 1.1 tools too, but it's not something I've recently confirmed is working.

So, I'd recommend building your tool for LTI Advantage and using the AGS 2.0 method if you can.

Hope that helps
Jake



Average of ratings: Useful (1)
In reply to Jake Dallimore

Re: Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

by Youness Madhoun -
Hello Jake ,

I thank you first for your answer, I applied the second solution but using postman I receive this error :

{
"status": 401,
"reason": "Unauthorized",
"request": {
"method": "POST",
"url": "/mod/lti/services.php/3/lineitems/22/lineitem/scores?type_id=8",
"accept": "*/*",
"contentType": "application/vnd.ims.lis.v1.score+json"
}
}

Please guide me for this issue ..
In reply to Youness Madhoun

Re: Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

by Jake Dallimore -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Youness,

That most likely comes from the fact that you're missing the relevant OAuth Authorization headers in the request. It could be thrown by this line (hard to say from the limited information however): https://github.com/moodle/moodle/blob/master/mod/lti/service/gradebookservices/classes/local/resources/lineitems.php#L87

Normally, this is handled by whatever library you're using, but since you're using postman, I'm not sure what you're doing to ensure this is being set/sent properly. I'd recommend making this call from your tool code directly, to guarantee the headers are generated and sent as they would be under normal use.

Cheers,
Jake
In reply to Jake Dallimore

Re: Missing or invalid consumer key - Sending Grades from External LTI system to Moodle 3.9

by Youness Madhoun -
Hello Jake ,

I use the pyLTIp3 library: https://pypi.org/project/PyLTI1p3/#configuration-using-django-admin-ui

and the problem is linked to the header to be able to authorize requests sent by Postman to query Moodle whether for Score or results, I will try to call moodle directly in my code and keep you in touch .

Thanks