ltijs: Grade ScorePublish code 400 bad request with Canvas
I’m having issues posting a grade in Canvas. I’m trying to run the following inside lti.onConnect() callback:
let grade = {
scoreGiven: 10,
activityProgress: 'Completed',
gradingProgress: 'FullyGraded'
}
await lti.Grade.ScorePublish(res.locals.token, grade);
The following is the debug output:
provider:gradeService Target platform: https://canvas.test.instructure.com +0ms
provider:gradeService Attempting to retrieve platform access_token for [https://canvas.test.instructure.com] +3ms
provider:platform Access_token for https://canvas.test.instructure.com not found +0ms
provider:platform Attempting to generate new access_token for https://canvas.test.instructure.com +0ms
provider:auth Awaiting return from the platform +44ms
provider:gradeService Response code 400 (Bad Request) +320ms
error log:
{ level: 'error',
message:
'Message: Response code 400 (Bad Request)\nStack: HTTPError: Response code 400 (Bad Request)\n at EventEmitter.emitter.on (/path-to-test-app/node_modules/got/source/as-promise.js:74:19)\n at process._tickCallback (internal/process/next_tick.js:68:7)',
timestamp: '2019-10-14T16:16:14.285Z' }
I can see I don’t have an access token in my database and lti.js is trying to get one from the platform. When I look at the console output of confjwt in Auth.js, it seems like I’m getting the appropriate client ID and endpoint (https://ouruniversity.test.instructure.com/login/oauth2/token) before the jwt sign, so I’m not sure why the request is bad.
Does anyone know what I might be doing wrong or can point me to where I can get more debug information?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 60 (30 by maintainers)
@Cvmcosta Hi sorry as well its been a while. I think the source of my issues was that i was trying to use a production instance of canvas with https with my localhost that was running http. Once i put up the test server on Heroku i did get the two sides communicating. Unfortunately i didn’t finish working on this as i didn’t have the support of my employer to continue. I can say that i was satisfied this would work but obviously to make sure that both the server and canvas are hosted via https
Aaaah, i think i get it. I don’t see how you would be able to do this without altering Ltijs.
You would have to change how Platforms are registered (to use Auth0 instead) and then change how these keys and Platforms are retrieved to get this data from Auth0.
But have in mind that Ltijs already provides all of this functionality, i don’t see a reason to use Auth0. As this person said, LTI doesnt have sign-in, it only uses the Client Credentials grant, and all of this functionality is already implemented.
@Cvmcosta Hi again just to keep the forum updated, i will be testing out your recommendations over the coming days. Once i have an update i will post back to the forum. Thanks again for the help.
@Cvmcosta yes, I can launch it, it works as I would expect. I even tried to open it in a new window to avoid any troubles with an iframe. Here is the debug output:
I copied the public key and here is a screenshot of these extra settings in moodle
@Cvmcosta Yes man, that will be great if you have an endpoint to provide the keys. Thanks man and great work